Skip to content

Commit 04b8306

Browse files
committed
C++: Add some more patterns.
1 parent d2e7f22 commit 04b8306

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

cpp/ql/lib/semmle/code/cpp/security/PrivateData.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ private string privateNames() {
2121
".*(" +
2222
// Inspired by the list on https://cwe.mitre.org/data/definitions/359.html
2323
// Government identifiers, such as Social Security Numbers
24-
"social.?security|" +
24+
"social.?security|national.?insurance|" +
2525
// Contact information, such as home addresses
26-
"post.?code|zip.?code|" +
26+
"post.?code|zip.?code|home.?address|" +
2727
// and telephone numbers
28-
"telephone|mobile|" +
28+
"telephone|home.?phone|mobile|fax.?no|fax.?number|" +
2929
// Geographic location - where the user is (or was)
3030
"latitude|longitude|" +
3131
// Financial data - such as credit card numbers, salary, bank accounts, and debts
32-
"credit.?card|salary|bank.?account|" +
32+
"credit.?card|debit.?card|salary|bank.?account|" +
3333
// Communications - e-mail addresses, private e-mail messages, SMS text messages, chat logs, etc.
34-
"email|employer|" +
34+
"email|" +
3535
// Health - medical conditions, insurance status, prescription records
36-
"medical" +
36+
"birthday|birth.?date|date.?of.?birth|medical|" +
37+
// Relationships - work and family
38+
"employer|spouse" +
3739
// ---
3840
").*"
3941
}

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/CleartextTransmission.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ edges
9696
| test3.cpp:532:45:532:58 | home_longitude | test3.cpp:533:15:533:20 | buffer |
9797
| test3.cpp:551:47:551:58 | salaryString | test3.cpp:552:15:552:20 | buffer |
9898
| test3.cpp:556:19:556:30 | salaryString | test3.cpp:559:15:559:20 | buffer |
99+
| test3.cpp:571:8:571:21 | call to get_home_phone | test3.cpp:572:14:572:16 | str |
100+
| test3.cpp:577:8:577:23 | call to get_home_address | test3.cpp:578:14:578:16 | str |
99101
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:21:48:27 | call to encrypt |
100102
| test.cpp:41:23:41:43 | cleartext password! | test.cpp:48:29:48:39 | thePassword |
101103
| test.cpp:66:23:66:43 | cleartext password! | test.cpp:76:21:76:27 | call to encrypt |
@@ -245,6 +247,10 @@ nodes
245247
| test3.cpp:552:15:552:20 | buffer | semmle.label | buffer |
246248
| test3.cpp:556:19:556:30 | salaryString | semmle.label | salaryString |
247249
| test3.cpp:559:15:559:20 | buffer | semmle.label | buffer |
250+
| test3.cpp:571:8:571:21 | call to get_home_phone | semmle.label | call to get_home_phone |
251+
| test3.cpp:572:14:572:16 | str | semmle.label | str |
252+
| test3.cpp:577:8:577:23 | call to get_home_address | semmle.label | call to get_home_address |
253+
| test3.cpp:578:14:578:16 | str | semmle.label | str |
248254
| test.cpp:41:23:41:43 | cleartext password! | semmle.label | cleartext password! |
249255
| test.cpp:48:21:48:27 | call to encrypt | semmle.label | call to encrypt |
250256
| test.cpp:48:29:48:39 | thePassword | semmle.label | thePassword |
@@ -294,3 +300,5 @@ subpaths
294300
| test3.cpp:533:3:533:6 | call to send | test3.cpp:532:45:532:58 | home_longitude | test3.cpp:533:15:533:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:532:45:532:58 | home_longitude | home_longitude |
295301
| test3.cpp:552:3:552:6 | call to send | test3.cpp:551:47:551:58 | salaryString | test3.cpp:552:15:552:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:551:47:551:58 | salaryString | salaryString |
296302
| test3.cpp:559:3:559:6 | call to send | test3.cpp:556:19:556:30 | salaryString | test3.cpp:559:15:559:20 | buffer | This operation transmits 'buffer', which may contain unencrypted sensitive data from $@ | test3.cpp:556:19:556:30 | salaryString | salaryString |
303+
| test3.cpp:572:2:572:5 | call to send | test3.cpp:571:8:571:21 | call to get_home_phone | test3.cpp:572:14:572:16 | str | This operation transmits 'str', which may contain unencrypted sensitive data from $@ | test3.cpp:571:8:571:21 | call to get_home_phone | call to get_home_phone |
304+
| test3.cpp:578:2:578:5 | call to send | test3.cpp:577:8:577:23 | call to get_home_address | test3.cpp:578:14:578:16 | str | This operation transmits 'str', which may contain unencrypted sensitive data from $@ | test3.cpp:577:8:577:23 | call to get_home_address | call to get_home_address |

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/test3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,11 @@ void tests3()
569569
const char *str;
570570

571571
str = get_home_phone();
572-
send(val(), str, strlen(str), val()); // BAD [NOT DETECTED]
572+
send(val(), str, strlen(str), val()); // BAD
573573

574574
str = get_home();
575575
send(val(), str, strlen(str), val()); // GOOD (probably not personal info)
576576

577577
str = get_home_address();
578-
send(val(), str, strlen(str), val()); // BAD [NOT DETECTED]
578+
send(val(), str, strlen(str), val()); // BAD
579579
}

0 commit comments

Comments
 (0)