Harry Maclean
e419fc9599
Make Code execution query more specific
...
Only the first argument to eval, instance_eval, send, class_send and
module_send is interpreted as Ruby code.
2021-10-05 10:28:34 +01:00
Arthur Baars
2f462771bb
Merge pull request #286 from github/aibaars/xxe
...
XXE query
2021-10-01 16:14:41 +02:00
Arthur Baars
c78d02d00d
Fix module of Parser::Options
2021-10-01 11:18:03 +02:00
Arthur Baars
b06bb7a789
Improve test cases
...
Set NONET (2048) by default.
2021-10-01 11:16:56 +02:00
Harry Maclean
8c0c08e887
Identify more instance of code injection
...
`class_eval` and `module_eval` both take a string as argument and
execute it as Ruby code.
2021-09-30 14:19:24 +01:00
Arthur Baars
089f9d87d4
Address comments
2021-09-30 11:20:23 +02:00
Arthur Baars
2b077595ae
Also track DTDLOAD and NONET
2021-09-30 11:20:23 +02:00
Arthur Baars
4268d9c565
XXE query
2021-09-30 11:20:17 +02:00
Harry Maclean
7191e1c007
Re-add delete_all and destroy_all methods
...
These methods don't take any arguments in Rails versions > 3, but
there's no harm in checking for them anyway, and some people might be
using very old Rails versions.
2021-09-30 09:39:58 +01:00
Harry Maclean
75bbc51e73
Make room for new test cases
...
This just bumps the other code down a bit so that the .expected diff is
easier to read.
2021-09-30 09:33:39 +01:00
Harry Maclean
615beeec80
Identify more vulnerable ActiveRecord methods
...
This change identifies the following patterns:
- `Model.select(input)`
- `Model.reselect(input)`
- `Model.rewhere(input)`
- `Model.update_all(input)`
- `model.reload(lock: input)`
2021-09-29 11:47:07 +01:00
Harry Maclean
270d13e4ac
Identify more vulnerable ActiveRecord methods
...
`find_by!`, `find_or_create_by`, `find_or_create_by!` and
`find_or_initialize_by` act similarly to `find_by`.
2021-09-29 10:49:14 +01:00
Harry Maclean
56919eee0b
delete/destroy_all -> delete/destroy_by
...
The ActiveRecord `delete_all` and `destroy_all` methods do not take a
condition argument - they act on the scope of their receiver.
The `delete_by` and `destroy_by` methods do take an argument which can
be raw SQL, and are therefore vulnerable to SQL injection.
For more info:
https://api.rubyonrails.org/v6.1.4/classes/ActiveRecord/Relation.html#method-i-delete_all
https://api.rubyonrails.org/v6.1.4/classes/ActiveRecord/Relation.html#method-i-delete_by
2021-09-29 10:45:54 +01:00
Harry Maclean
3a1b294c21
Identify more ActiveRecord calculate methods
...
`average`, `count`, `maximum`, `minimum` and `sum` are all convenience
methods that call `calculate(:<method name>, ...)` under the hood.
Therefore they are vulnerable to SQL injection too.
2021-09-29 10:11:38 +01:00
Harry Maclean
4f9518a9c6
Merge pull request #293 from github/hmac-code-injection
...
Add query for Code Injection
2021-09-23 13:50:48 +01:00
Alex Ford
d1f2258d45
revamp weak file permissions query
2021-09-21 19:02:11 +01:00
Nick Rolfe
d27f8a6d24
Add empty subpaths section to expected test output
2021-09-20 15:56:58 +01:00
Nick Rolfe
6f7d4fef70
Merge pull request #287 from github/unsafe-deserialization
...
rb/unsafe-deserialization query
2021-09-20 14:23:30 +01:00
Harry Maclean
95e50cedad
Add query for Code Injection
...
This query finds cases where user input flows to an argument to `eval`
or `send`, which can execute arbitrary Ruby code.
2021-09-20 11:35:45 +01:00
Harry Maclean
916b844557
Merge pull request #280 from github/hmac-cli-injection
...
Add CLI Injection query
2021-09-20 08:54:01 +01:00
Alex Ford
36289aa9d9
Merge pull request #255 from github/reflected-xss
...
rb/reflected-xss query
2021-09-17 18:32:48 +01:00
Harry Maclean
739661eb10
Test that KernelMethodCall is specific enough
...
Calls to `UnknownModule.system`, where `UnknownModule` is a module that
we know nothing about, should not be identified as instances of
`KernelMethodCall`.
2021-09-17 17:02:17 +01:00
Harry Maclean
599dc28ffa
Add another test for shell interpretation
2021-09-17 17:02:17 +01:00
Harry Maclean
f8359767bc
Exclude non-shell interpreted args
...
Update the CommandInjection query to only consider sinks where the
argument is interpreted by a shell. If the argument is passed directly
to a subprocess then it's not vulnerable to shell injection.
2021-09-17 17:02:17 +01:00
Harry Maclean
c8e9a592f0
Update CLI injection tests
...
Cover more cases, like sinks after (but not guarded by) barrier guards.
2021-09-17 17:02:17 +01:00
Harry Maclean
fb23a2e3bf
Add SubshellHeredocExecution
...
This is a form of command execution:
result = <<`EOF`
echo foo bar #{baz}
EOF
2021-09-17 17:02:17 +01:00
Harry Maclean
799ef4e4c9
Add barrier guards for CLI injection
2021-09-17 17:02:17 +01:00
Harry Maclean
8f65d78cb5
Add Shellwords.escape as CLI injection sanitizer
2021-09-17 17:02:17 +01:00
Harry Maclean
4a0d7c528a
Add top-level CLI injection query and tests
2021-09-17 17:02:17 +01:00
Nick Rolfe
3d23575a38
Merge pull request #292 from github/regexp_slash_az
...
Don't parse `\A` and `\Z` as `RegExpConstant`
2021-09-17 16:42:13 +01:00
Alex Ford
e89d485bc0
update test output (subpaths)
2021-09-15 20:51:14 +01:00
Alex Ford
773291e4c3
Put exprNodeReturnedFrom predicate in DataFlowDispatch.qll
2021-09-15 20:50:46 +01:00
Alex Ford
e80faa017c
Fix rb/reflected-xss flow from helper method return values
2021-09-15 20:50:46 +01:00
Alex Ford
50b0bb8b36
Restrict rb/reflected-xss instance variable taint edges
2021-09-15 20:50:46 +01:00
Alex Ford
5cfefb1027
Add some more test cases for rb/reflected-xss
2021-09-15 20:50:46 +01:00
Alex Ford
76864a82be
remove an incorrect test case
2021-09-15 20:50:46 +01:00
Alex Ford
3445a6a5e7
fix flow steps from controller instance var assignement to view read access
2021-09-15 20:50:46 +01:00
Alex Ford
b993723595
remove spurious ivar -> locals hash mapping (actionview/controller)
2021-09-15 20:50:46 +01:00
Alex Ford
3430a46440
fix some local variable mappings between view and controller
2021-09-15 20:50:46 +01:00
Alex Ford
d71dd3f6c7
rb/reflected-xss
2021-09-15 20:50:46 +01:00
Tom Hvitved
9e67382f06
Bump codeql submodule
2021-09-15 14:59:42 +02:00
Nick Rolfe
ebf23d00d1
Don't parse \A and \Z as RegExpConstant
...
Fixes some FPs for the ReDoS queries.
2021-09-14 16:49:35 +01:00
Harry Maclean
8f36b0d7fe
Simplify guard in SQL injection tests
...
We don't (yet) properly sanitize taint in cases like this
foo = "A" unless foo == "B"
So for now, use a simpler guard in the SQL injection test.
We can resurrect the old, more idiomatic guard when we can support it.
2021-09-10 16:27:57 +01:00
Nick Rolfe
2ddca2c0db
Document and test YAML.safe_load
2021-09-08 18:22:31 +01:00
Nick Rolfe
760dbd739d
Add test for rb/unsafe-deserialization
2021-09-08 17:49:23 +01:00
Nick Rolfe
7666d856b7
Merge remote-tracking branch 'origin/main' into polynomial_redos
2021-09-07 17:35:07 +01:00
Harry Maclean
87253032e2
Add a query for URL redirect vulnerabilities
...
This query finds instances of CWE-601: Redirection to Untrusted Site.
The structure is copied from a query of the same name in the Python
library. We add customisations specific to `ActionController`.
2021-09-03 13:17:14 +01:00
Nick Rolfe
47e5a8fd09
Add test for polynomial ReDoS query
2021-09-02 17:57:56 +01:00
Nick Rolfe
cbe23661ed
Rename exponential ReDoS test directory
2021-09-02 17:57:56 +01:00
Erik Krogh Kristensen
632ad518f0
enable unicode parsing in the ruby ReDoS query
2021-08-02 07:13:41 +00:00