Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize operators #182

Merged
merged 3 commits into from
Apr 10, 2016
Merged

Sanitize operators #182

merged 3 commits into from
Apr 10, 2016

Conversation

obi1kenobi
Copy link
Contributor

On March 28th 2015, I discovered and reported five SQL injection vulnerabilities to the owners of this repository. In private discussion, we decided to settle the problem via this pull request that will be merged as quickly as possible, to minimize the possible security impact.

Here is the summary of the five vulnerabilities:

  • The LIKE operator argument isn't sanitized.
> graph.query(Region).filter(Region.name.like("United States' or 'a'='a")).all()
SELECT statement: SELECT FROM Region WHERE name like 'United States' or 'a'='a'
  • The BETWEEN operator's first input isn't quoted (for strings) or sanitized
> graph.query(Region).filter(Region.name.between('United States" or "a"="a', 'zzzz" or "a"="a')).all()
SELECT statement: SELECT FROM Region WHERE name BETWEEN United States" or "a"="a and "zzzz\" or \"a\"=\"a"
  • The MATCHES argument isn't sanitized.
> graph.query(Region).filter(Region.name.matches("United States' OR 'a'='a")).all()
SELECT statement: SELECT FROM Region WHERE name matches 'United States' OR 'a'='a'
  • The STARTSWITH argument isn't sanitized.
> graph.query(Region).filter(Region.name.startswith("United States' OR 'a%'='a")).all 
SELECT statement: SELECT FROM Region WHERE name like 'United States' OR 'a%'='a%'
  • The ENDSWITH argument isn't sanitized.
> graph.query(Region).filter(Region.name.endswith("United States' OR 'a'='a")).all 
SELECT statement: SELECT FROM Region WHERE name like '%United States' OR 'a'='a'

This pull request addresses all these issues.

@Ostico Ostico merged commit 2285eb4 into mogui:develop Apr 10, 2016
@obi1kenobi obi1kenobi deleted the sanitize_operators branch April 10, 2016 17:13
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 79.706% when pulling 333b257 on kensho:sanitize_operators into cf9345e on mogui:develop.

Ostico added a commit that referenced this pull request Apr 10, 2016
Fix vulnerability:
Sanitize operators #182
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.

4 participants