Skip to content

Commit c8cfb6a

Browse files
authored
Merge pull request github#12065 from knewbury01/knewbury01/fix-js-cleartext-logging-doc
Update JS CleartextLogging qhelp
2 parents 55cd436 + 21b4931 commit c8cfb6a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

javascript/ql/src/Security/CWE-312/CleartextLogging.qhelp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,33 @@
22
"-//Semmle//qhelp//EN"
33
"qhelp.dtd">
44
<qhelp>
5-
<include src="CleartextStorage.qhelp" /></qhelp>
5+
6+
<overview>
7+
8+
<p>If sensitive data is written to a log entry it could be exposed to an attacker
9+
who gains access to the logs.</p>
10+
11+
<p>Potential attackers can obtain sensitive user data when the log output is displayed. Additionally that data may
12+
expose system information such as full path names, system information, and sometimes usernames and passwords.</p>
13+
</overview>
14+
15+
<recommendation>
16+
<p>
17+
Sensitive data should not be logged.
18+
</p>
19+
</recommendation>
20+
21+
<example>
22+
<p>In the example the entire process environment is logged using `console.info`. Regular users of the production deployed application
23+
should not have access to this much information about the environment configuration.
24+
</p>
25+
<sample src="examples/CleartextLogging.js" />
26+
27+
<p> In the second example the data that is logged is not sensitive.</p>
28+
<sample src="examples/CleartextLoggingGood.js" />
29+
</example>
30+
31+
<references>
32+
<li>OWASP: <a href="https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/">Insertion of Sensitive Information into Log File</a>.</li>
33+
</references>
34+
</qhelp>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// BAD: Logging cleartext sensitive data
2+
console.info(`[INFO] Environment: ${process.env}`);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let not_sensitive_data = { a: 1, b : 2}
2+
// GOOD: it is fine to log data that is not sensitive
3+
console.info(`[INFO] Some object contains: ${not_sensitive_data}`);

0 commit comments

Comments
 (0)