Commit aa540fe
committed
Excape
Previously when doing a `match` operation against an activerecord string
field, we passed down the string directly and surrounded it with `%` on
either side, allowing a substring match of the column. There was
nothing preventing a client from including additional `%` wildcard
characters in their query string to add more advanced substring
matching. The problem with this is that if an attacker provides a few
dozen wildcard characters, the sql engine can very quickly run into
processing problems and cause a Denial of Service against the
database/application.
This commit takes advantage of activerecord and arel's sql escaping
behavior to make this safe, at the tradeoff of not being able to pass
additional wildcard characters as part of queries. Note that rails 4.x
has fewer APIs for this behavior and they aren't all public. Because
that is now an unsupported version of rails, this PR simply keeps the
less safe older behavior when that version of activerecord is detected.match operations to prevent DoS queries1 parent 1fbef6e commit aa540fe
File tree
2 files changed
+42
-5
lines changed- lib/graphiti/adapters
- spec/integration/rails
2 files changed
+42
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
87 | 106 | | |
88 | 107 | | |
89 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
266 | 284 | | |
267 | 285 | | |
268 | 286 | | |
| |||
0 commit comments