Skip to content

fix(oracle): harden date literal escaping#18216

Open
WikiRik wants to merge 1 commit into
mainfrom
WikiRik/oracle-escape-string-guard
Open

fix(oracle): harden date literal escaping#18216
WikiRik wants to merge 1 commit into
mainfrom
WikiRik/oracle-escape-string-guard

Conversation

@WikiRik
Copy link
Copy Markdown
Member

@WikiRik WikiRik commented Apr 15, 2026

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description of Changes

This PR simplifies the workaround done in escapeString for oracle. It also adds additional unit tests, although we'll move them to the oracle package later.

@WikiRik WikiRik marked this pull request as ready for review April 15, 2026 12:10
@WikiRik WikiRik requested a review from a team as a code owner April 15, 2026 12:10
@WikiRik WikiRik requested review from ephys and sdepold April 15, 2026 12:10
Copy link
Copy Markdown
Member

@ephys ephys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though this PR tries to harden it, this is still a massive security hole and the approach should be changed asap

@@ -117,7 +117,7 @@ export class OracleDialect extends AbstractDialect<OracleDialectOptions, OracleC

escapeString(val: string): string {
if (val.startsWith('TO_TIMESTAMP_TZ') || val.startsWith('TO_DATE')) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this at all? Any exception to string escapes is extremely dangerous

This must be removed asap. All user-provided strings go through this. They'll be able to call TO_TIMESTAMP_TZ/TO_DATE on anything

}

return this.escape(date);
return `TO_DATE('${formattedDate}','${format}')`;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toBindableValue should never return a function call like this, this makes no sense. It's only supposed to return a value. The return value of toBindableValue is meant to be escaped

The SQL must be added to getBindParamSql and escape

@WikiRik
Copy link
Copy Markdown
Member Author

WikiRik commented May 3, 2026

@ephys Thanks for the review! I agree that this is not a nice solution, but with how DataTypes are implemented I didn't see another easy fix back in the day. Maybe you can take a look at it from scratch to see how we can work around the requirement of Oracle to have that TO_TIMESTAMP_TZ/TO_DATE in there without doing a bypass of the escape function?

@ephys
Copy link
Copy Markdown
Member

ephys commented May 3, 2026

I can definitely take a look :)

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