Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions llm_vuln.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// LLM integration with user input directly in prompt
async function askAI(userInput: string) {
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: userInput }
]
});
return response.choices[0].message.content;
}

// Dangerous: user controls system prompt
async function customAssistant(systemPrompt: string, question: string) {
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: question }
]
});
return response.choices[0].message.content;
}