Add mojo-security-validation opengrep rule for Chromium#865
Add mojo-security-validation opengrep rule for Chromium#865
Conversation
| public: | ||
| // SHOULD TRIGGER: File path without validation (dangerous) | ||
| // ruleid: chromium-mojo-privilege-validation | ||
| void ReadFile(const base::FilePath& file_path) override { |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] Mojo interface methods that receive privilege-presuming data (like file paths,
origins, or URLs) should validate this data using ChildProcessSecurityPolicy
before use. Untrusted processes can send arbitrary data over IPC.
Use methods like CanAccessDataForOrigin(), CanReadFile(), etc.
Source: https://github.com/brave/security-action/blob/main/assets/opengrep_rules/client/mojo-security-validation.yaml
Cc @thypon @cdesouza-chromium
|
|
||
| // SHOULD TRIGGER: URL without origin validation (dangerous) | ||
| // ruleid: chromium-mojo-privilege-validation | ||
| void FetchResource(const GURL& url, int render_process_id) override { |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] Mojo interface methods that receive privilege-presuming data (like file paths,
origins, or URLs) should validate this data using ChildProcessSecurityPolicy
before use. Untrusted processes can send arbitrary data over IPC.
Use methods like CanAccessDataForOrigin(), CanReadFile(), etc.
Source: https://github.com/brave/security-action/blob/main/assets/opengrep_rules/client/mojo-security-validation.yaml
Cc @thypon @cdesouza-chromium
|
|
||
| // SHOULD TRIGGER: Origin without validation (dangerous) | ||
| // ruleid: chromium-mojo-privilege-validation | ||
| void AccessOriginData(const url::Origin& origin, int pid) override { |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] Mojo interface methods that receive privilege-presuming data (like file paths,
origins, or URLs) should validate this data using ChildProcessSecurityPolicy
before use. Untrusted processes can send arbitrary data over IPC.
Use methods like CanAccessDataForOrigin(), CanReadFile(), etc.
Source: https://github.com/brave/security-action/blob/main/assets/opengrep_rules/client/mojo-security-validation.yaml
Cc @thypon @cdesouza-chromium
badd7f7 to
f12c92c
Compare
Enforce privilege validation in Mojo IPC handlers to prevent privilege escalation through IPC message spoofing.
f12c92c to
7301cca
Compare
Opengrep Findings📈 Comparison Results
Summary by Rule
Detailed Findings
|
| patterns: | ||
| - patterns: | ||
| - pattern-either: | ||
| - pattern-regex: void\s+\w+\([^)]*base::FilePath[^)]*\)\s*override\s*\{ |
There was a problem hiding this comment.
as mentioned in the original PR I think this is far too broad and it would be better to target the mojom files directly instead of the cpp unless you can filter on classes that subclass mojom::*?
Supersedes: #855