Skip to content

#576 Escape single quotes in query interpolation#615

Open
VasilevNStas wants to merge 5 commits into
zerocracy:masterfrom
VasilevNStas:576-query-injection
Open

#576 Escape single quotes in query interpolation#615
VasilevNStas wants to merge 5 commits into
zerocracy:masterfrom
VasilevNStas:576-query-injection

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Problem

Factbase query strings are built via string interpolation with user-supplied values (area, judge). If these contain a single quote ('), the query syntax breaks, allowing query injection.

Solution

Doubled single quotes ("''") in all user-supplied values interpolated into query strings, matching SQL-style escaping:

  • regularly.rb: area and judge in queries
  • repeatedly.rb: area and judge in all 4 queries

Numeric values (interval, hours) and bare identifiers (p_every_days, p_every_hours) are not affected since they don't appear inside quoted strings.

Closes #576

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 plz review this PR

@yegor256

Copy link
Copy Markdown
Member

@VasilevNStas why no tests?

@VasilevNStas VasilevNStas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yegor256
You are right, my apologies. Added tests for area and judge with single quotes in both files.

@VasilevNStas VasilevNStas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right, my apologies. Added tests for area and judge with single quotes in both files.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256
plz review

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.

Query injection via unsanitized string interpolation in regularly.rb and repeatedly.rb

2 participants