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

Reduce false positives count in security reports #3851

Merged
merged 7 commits into from
Nov 13, 2019
Merged

Reduce false positives count in security reports #3851

merged 7 commits into from
Nov 13, 2019

Conversation

javierm
Copy link
Member

@javierm javierm commented Nov 13, 2019

Background

Some security tools like brakeman generate automatic reports containing possible security vulnerabilities. While many of them are false positives, they generate noise which makes it hard to focus on real vulnerabilities.

Objectives

  • Refactor code to reduce the number of false positives in security reports
  • Add CSRF protection to management controllers
  • Avoid executing JavaScript code through banner URLs

Notes

There are still a few false positives, related to SQL injection and dynamic render paths. We might address them in the future.

It was being incorrectly detected as used in a dangerous send. We can
get rid of the warning by taking advantage of the `has_orders` method
and getting rid of this code.
This was actually a false positive, since our new regular expression
does the exact same thing. However, false positives generate noise and
make it harder to deal with real issues, so I'm changing it anyway.

We could add a more advanced regular expression, like
`URI::MailTo::EMAIL_REGEXP`. However, this expression marks emails with
non-English characters as invalid, when in practice it's possible to
have an email address with non-English characters.
@javierm javierm added the security Pull requests that address a security vulnerability label Nov 13, 2019
@javierm javierm self-assigned this Nov 13, 2019
@javierm javierm added this to Reviewing in Roadmap via automation Nov 13, 2019
@javierm javierm changed the title Reduce number of false positives in security reports Decrease false positives in security reports Nov 13, 2019
@javierm javierm changed the title Decrease false positives in security reports Reduce false positives count in security reports Nov 13, 2019
@javierm javierm force-pushed the security branch 2 times, most recently from 14f201a to c3740ad Compare November 13, 2019 02:30
We make the code easier to read and at the same time we remove a SQL
injection false positive regarding the use of `WHERE id = #{id}`.

We still get a warning about SQL injection regarding the `tsv =` part.
It's a false positive, since the value of that parameter does not
depend on user input.
Using `sanitize` we make sure the `href` attribute does not execute any
dangerous code. The possibility of a banner pointing to a dangerous URL
was very reduced, though, since only administrators can edit this
attribute.
In this case using `joins` doesn't prevent N+1 queries to get titles for
every record, and since we cannot order translations with just SQL due
to fallbacks, we don't need it.

Automatic SQL injection checks were showing a false positive in this
scope; there was no real vulnerability here because foreign keys, table
names and locales were under our control.
@javierm javierm merged commit 70cc7de into master Nov 13, 2019
Roadmap automation moved this from Reviewing to Release 1.1.0 Nov 13, 2019
@javierm javierm deleted the security branch November 13, 2019 19:15
smarques pushed a commit to venetochevogliamo/consul that referenced this pull request Apr 29, 2020
Reduce false positives count in security reports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security Pull requests that address a security vulnerability
Projects
No open projects
Roadmap
  
Release 1.1.0
Development

Successfully merging this pull request may close these issues.

None yet

1 participant