Skip to content

[opencode] VULN-117372 Fix SQL injection vulnerability in durable-chat-template#958

Merged
deloreyj merged 1 commit intocloudflare:mainfrom
kale-stew:kylie/address-do-template-vuln
Mar 9, 2026
Merged

[opencode] VULN-117372 Fix SQL injection vulnerability in durable-chat-template#958
deloreyj merged 1 commit intocloudflare:mainfrom
kale-stew:kylie/address-do-template-vuln

Conversation

@kale-stew
Copy link
Contributor

Description

Fixes #VULN-117372

Have tested changes with a deployed version of the DO template: https://durable-chat-template.kylieski.workers.dev

Description from OpenCode:

This change fixes a SQL injection vulnerability in the durable-chat-template. The saveMessage method was building SQL queries using string interpolation, which is dangerous because user-provided values (like message.user or message.content) were being inserted directly into the query string.

Before:

this.ctx.storage.sql.exec(
  `INSERT INTO messages (id, user, role, content) VALUES ('${message.id}', '${message.user}', ...)`
);

After:

this.ctx.storage.sql.exec(
  `INSERT INTO messages (id, user, role, content) VALUES (?, ?, ?, ?) ...`,
  message.id,
  message.user,
  message.role,
  message.content,
);

Using parameterized queries (? placeholders) ensures user input is properly escaped and can never be interpreted as SQL commands.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Preview link not generated: you must be on a branch, not on a fork.
Collaborators may enable previews for this pull request by attaching the allow preview label.
If you are already a collaborator, please create a branch rather than forking.

@deloreyj deloreyj merged commit 04a288c into cloudflare:main Mar 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants