Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c6923c

Browse files
committed
C++: Improve and differentiate the qhelp.
1 parent 88b7a08 commit 5c6923c

6 files changed

Lines changed: 19 additions & 9 deletions

cpp/ql/src/Security/CWE/CWE-497/ExposedSystemData.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<overview>
66
<p>Exposing system data or debugging information may help an adversary to learn about the system and form an attack plan. An attacker can use error messages that reveal technologies, operating systems, and product versions to tune their attack against known vulnerabilities in these technologies.</p>
77

8-
<p>This query finds locations where system configuration information might be revealed to a user.</p>
8+
<p>This query finds locations where system configuration information might be revealed to a remote user.</p>
99
</overview>
1010

1111
<recommendation>
12-
<p>Do not expose system configuration information to users. Be wary of the difference between information that could be helpful to users, and unnecessary details that could be useful to an adversary.</p>
12+
<p>Do not expose system configuration information to remote users. Be wary of the difference between information that could be helpful to users, and unnecessary details that could be useful to an adversary.</p>
1313
</recommendation>
1414

1515
<example>

cpp/ql/src/Security/CWE/CWE-497/ExposedSystemDataCorrect.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ char* path = getenv("PATH");
22

33
//...
44

5-
fprintf(stderr, "A required executable file could not be found. " \
6-
"Please ensure that the software has been installed " \
7-
"correctly or contact a system administrator.\n");
5+
message = "An internal error has occurred. Please try again or contact a system administrator.\n";
6+
send(socket, message, strlen(message), 0);

cpp/ql/src/Security/CWE/CWE-497/ExposedSystemDataIncorrect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ char* path = getenv("PATH");
22

33
//...
44

5-
fprintf(stderr, "cannot find exe on path %s\n", path);
5+
sprintf(buffer, "Cannot find exe on path: %s", path);
6+
send(socket, buffer, strlen(buffer), 0);

cpp/ql/src/Security/CWE/CWE-497/PotentiallyExposedSystemData.qhelp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<overview>
66
<p>Exposing system data or debugging information may help an adversary to learn about the system and form an attack plan. An attacker can use error messages that reveal technologies, operating systems, and product versions to tune their attack against known vulnerabilities in these technologies.</p>
77

8-
<p>This query finds locations where system configuration information might be revealed to a user.</p>
8+
<p>This query finds locations where system configuration information that is particularly sensitive might be revealed to a user.</p>
99
</overview>
1010

1111
<recommendation>
@@ -15,11 +15,11 @@
1515
<example>
1616
<p>In this example the value of the <code>PATH</code> environment variable is revealed in full to the user when a particular error occurs. This might reveal information such as the software installed on your system to an adversary who does not have legitimate access to that information.</p>
1717

18-
<sample src="ExposedSystemDataIncorrect.cpp" />
18+
<sample src="PotentiallyExposedSystemDataIncorrect.cpp" />
1919

2020
<p>The message should be rephrased without this information, for example:</p>
2121

22-
<sample src="ExposedSystemDataCorrect.cpp" />
22+
<sample src="PotentiallyExposedSystemDataCorrect.cpp" />
2323
</example>
2424

2525
<references>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
char* key = getenv("APP_KEY");
2+
3+
//...
4+
5+
fprintf(stderr, "Application key not recognized. Please ensure the key is correct or contact a system administrator.\n", key);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
char* key = getenv("APP_KEY");
2+
3+
//...
4+
5+
fprintf(stderr, "Key not recognized: %s\n", key);

0 commit comments

Comments
 (0)