-
Notifications
You must be signed in to change notification settings - Fork 3
Add sensitive exposure split query #207
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2915d6b
Add sensitive exposure split query
knewbury01 d7995ce
Rename sensitive-exposure-likely to heuristic
knewbury01 ad9e4fe
Change query id SensitiveExposureHeuristicSource.ql
knewbury01 c6ad123
Address review comments
knewbury01 0291022
Address review comments second round
knewbury01 9be950c
Add more documentation to allowImplicitRead in SensitiveExposureHeuri…
knewbury01 88848a4
Merge branch 'main' into knewbury01/cap-sensitive-sources
jeongsoolee09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...cript/frameworks/cap/src/sensitive-exposure/SensitiveExposureHeuristicSource.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # CAP Insertion of Sensitive Information into Log File | ||
|
|
||
| If sensitive information is written to a log entry using the CAP Node.js logging API, a malicious user may be able to gain access to user data. | ||
|
|
||
| Data that may expose system information such as full path names, system information, usernames and passwords should not be logged. | ||
|
|
||
| ## Recommendation | ||
|
|
||
| CAP applications should not log sensitive information. | ||
|
|
||
| ## Examples | ||
|
|
||
| This CAP service directly logs the sensitive information. | ||
knewbury01 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ``` javascript | ||
| import cds from '@sap/cds' | ||
| const LOG = cds.log("logger"); | ||
|
|
||
| class SampleVulnService extends cds.ApplicationService { | ||
| init() { | ||
| LOG.info(`[INFO] Environment: ${JSON.stringify(process.env)}`); // CAP log exposure alert | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| - OWASP 2021: [Security Logging and Monitoring Failures](https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/). | ||
| - OWASP: [Logging Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html). | ||
| - OWASP: [User Privacy Protection Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/User_Privacy_Protection_Cheat_Sheet.html). | ||
31 changes: 31 additions & 0 deletions
31
javascript/frameworks/cap/src/sensitive-exposure/SensitiveExposureHeuristicSource.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * @name Insertion of sensitive information into log files | ||
| * @description Writing heuristically sensitive information to log files can allow that | ||
| * information to be leaked to an attacker more easily. | ||
| * @kind path-problem | ||
| * @problem.severity warning | ||
| * @security-severity 7.5 | ||
| * @precision low | ||
| * @id js/cap-sensitive-log-heurisitic-source | ||
| * @tags security | ||
| * external/cwe/cwe-532 | ||
| */ | ||
|
|
||
| import javascript | ||
| import advanced_security.javascript.frameworks.cap.CDS | ||
| import advanced_security.javascript.frameworks.cap.CAPLogInjectionQuery | ||
| private import semmle.javascript.security.dataflow.CleartextLoggingCustomizations::CleartextLogging as CleartextLogging | ||
| import DataFlow::PathGraph | ||
|
|
||
| class SensitiveLogExposureConfig extends TaintTracking::Configuration { | ||
| SensitiveLogExposureConfig() { this = "SensitiveLogExposure" } | ||
|
|
||
| override predicate isSource(DataFlow::Node source) { source instanceof CleartextLogging::Source } | ||
|
|
||
| override predicate isSink(DataFlow::Node sink) { sink instanceof CdsLogSink } | ||
knewbury01 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| from SensitiveLogExposureConfig config, DataFlow::PathNode source, DataFlow::PathNode sink | ||
| where config.hasFlowPath(source, sink) | ||
| select sink, source, sink, "This logs sensitive data returned by $@ as clear text.", | ||
| source.getNode(), source.getNode().(CleartextLogging::Source).describe() | ||
17 changes: 17 additions & 0 deletions
17
...ive-exposure/sensitive-exposure-js-all-sinks/sensitive-exposure-heuristic-source.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| WARNING: module 'PathGraph' has been deprecated and may be removed in future (SensitiveExposureHeuristicSource.ql:18,8-27) | ||
| WARNING: type 'Configuration' has been deprecated and may be removed in future (SensitiveExposureHeuristicSource.ql:20,42-70) | ||
| WARNING: type 'PathNode' has been deprecated and may be removed in future (SensitiveExposureHeuristicSource.ql:28,41-59) | ||
| WARNING: type 'PathNode' has been deprecated and may be removed in future (SensitiveExposureHeuristicSource.ql:28,68-86) | ||
| nodes | ||
| | sensitive-exposure-heuristic-source.js:6:18:6:69 | `[INFO] ... .env)}` | | ||
| | sensitive-exposure-heuristic-source.js:6:18:6:69 | `[INFO] ... .env)}` | | ||
| | sensitive-exposure-heuristic-source.js:6:41:6:67 | JSON.st ... ss.env) | | ||
| | sensitive-exposure-heuristic-source.js:6:56:6:66 | process.env | | ||
| | sensitive-exposure-heuristic-source.js:6:56:6:66 | process.env | | ||
| edges | ||
| | sensitive-exposure-heuristic-source.js:6:41:6:67 | JSON.st ... ss.env) | sensitive-exposure-heuristic-source.js:6:18:6:69 | `[INFO] ... .env)}` | | ||
| | sensitive-exposure-heuristic-source.js:6:41:6:67 | JSON.st ... ss.env) | sensitive-exposure-heuristic-source.js:6:18:6:69 | `[INFO] ... .env)}` | | ||
| | sensitive-exposure-heuristic-source.js:6:56:6:66 | process.env | sensitive-exposure-heuristic-source.js:6:41:6:67 | JSON.st ... ss.env) | | ||
| | sensitive-exposure-heuristic-source.js:6:56:6:66 | process.env | sensitive-exposure-heuristic-source.js:6:41:6:67 | JSON.st ... ss.env) | | ||
| #select | ||
| | sensitive-exposure-heuristic-source.js:6:18:6:69 | `[INFO] ... .env)}` | sensitive-exposure-heuristic-source.js:6:56:6:66 | process.env | sensitive-exposure-heuristic-source.js:6:18:6:69 | `[INFO] ... .env)}` | This logs sensitive data returned by $@ as clear text. | sensitive-exposure-heuristic-source.js:6:56:6:66 | process.env | process environment | |
8 changes: 8 additions & 0 deletions
8
...sensitive-exposure/sensitive-exposure-js-all-sinks/sensitive-exposure-heuristic-source.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import cds from '@sap/cds' | ||
| const LOG = cds.log("logger"); | ||
|
|
||
| class SampleVulnService extends cds.ApplicationService { | ||
| init() { | ||
| LOG.info(`[INFO] Environment: ${JSON.stringify(process.env)}`); // CAP log exposure alert | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
...sitive-exposure/sensitive-exposure-js-all-sinks/sensitive-exposure-heuristic-source.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| sensitive-exposure/SensitiveExposureHeuristicSource.ql |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.