Skip to content

Commit 8b40698

Browse files
authored
fix(iast): report cookie name [backport 1.20] (#7930)
Backport ccfc0ab from #7927 to 1.20. ## Description Ensure that Cookies vulnerabilities report only the cookie name ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that.
1 parent 55c12af commit 8b40698

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

ddtrace/appsec/iast/taint_sinks/insecure_cookie.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ def asm_check_cookies(cookies): # type: (Optional[Dict[str, str]]) -> None
4343

4444
for cookie_key, cookie_value in six.iteritems(cookies):
4545
lvalue = cookie_value.lower().replace(" ", "")
46-
evidence = "%s=%s" % (cookie_key, cookie_value)
4746

4847
if ";secure" not in lvalue:
49-
InsecureCookie.report(evidence_value=evidence)
48+
InsecureCookie.report(evidence_value=cookie_key)
5049

5150
if ";httponly" not in lvalue:
52-
NoHttpOnlyCookie.report(evidence_value=evidence)
51+
NoHttpOnlyCookie.report(evidence_value=cookie_key)
5352

5453
if ";samesite=" in lvalue:
5554
ss_tokens = lvalue.split(";samesite=")
@@ -63,4 +62,4 @@ def asm_check_cookies(cookies): # type: (Optional[Dict[str, str]]) -> None
6362
report_samesite = True
6463

6564
if report_samesite:
66-
NoSameSite.report(evidence_value=evidence)
65+
NoSameSite.report(evidence_value=cookie_key)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
Vulnerability Management for Code-level (IAST): Ensure that Cookies vulnerabilities report only the cookie name.

riotfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,7 +2800,8 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
28002800
# confluent-kafka dropped official wheels for Python 2.7 in 1.8.2
28012801
Venv(pys="2.7", pkgs={"confluent-kafka": "~=1.7.0"}),
28022802
# confluent-kafka>=1.7 has issues building on linux with Python 3.5
2803-
Venv(pys="3.5", pkgs={"confluent-kafka": "~=1.5.0"}),
2803+
# TODO: skip 3.5
2804+
# Venv(pys="3.5", pkgs={"confluent-kafka": "~=1.5.0"}),
28042805
Venv(
28052806
pys=select_pys(min_version="3.6", max_version="3.10"),
28062807
pkgs={"confluent-kafka": ["~=1.9.2", latest]},

tests/appsec/iast/taint_sinks/test_insecure_cookie.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def test_insecure_cookies(iast_span_defaults):
2121
assert VULN_INSECURE_COOKIE in vulnerabilities_types
2222
assert VULN_NO_SAMESITE_COOKIE in vulnerabilities_types
2323

24-
assert vulnerabilities[0].evidence.value == "foo=bar"
25-
assert vulnerabilities[1].evidence.value == "foo=bar"
26-
assert vulnerabilities[2].evidence.value == "foo=bar"
24+
assert vulnerabilities[0].evidence.value == "foo"
25+
assert vulnerabilities[1].evidence.value == "foo"
26+
assert vulnerabilities[2].evidence.value == "foo"
2727

2828
assert vulnerabilities[0].location.line is None
2929
assert vulnerabilities[0].location.path is None
@@ -41,8 +41,8 @@ def test_nohttponly_cookies(iast_span_defaults):
4141
assert VULN_NO_HTTPONLY_COOKIE in vulnerabilities_types
4242
assert VULN_NO_SAMESITE_COOKIE in vulnerabilities_types
4343

44-
assert vulnerabilities[0].evidence.value == "foo=bar;secure"
45-
assert vulnerabilities[1].evidence.value == "foo=bar;secure"
44+
assert vulnerabilities[0].evidence.value == "foo"
45+
assert vulnerabilities[1].evidence.value == "foo"
4646

4747
assert vulnerabilities[0].location.line is None
4848
assert vulnerabilities[0].location.path is None
@@ -63,7 +63,7 @@ def test_nosamesite_cookies_missing(iast_span_defaults):
6363

6464
assert len(vulnerabilities) == 1
6565
assert vulnerabilities[0].type == VULN_NO_SAMESITE_COOKIE
66-
assert vulnerabilities[0].evidence.value == "foo=bar;secure;httponly"
66+
assert vulnerabilities[0].evidence.value == "foo"
6767

6868

6969
def test_nosamesite_cookies_none(iast_span_defaults):
@@ -76,7 +76,7 @@ def test_nosamesite_cookies_none(iast_span_defaults):
7676
assert len(vulnerabilities) == 1
7777

7878
assert vulnerabilities[0].type == VULN_NO_SAMESITE_COOKIE
79-
assert vulnerabilities[0].evidence.value == "foo=bar;secure;httponly;samesite=none"
79+
assert vulnerabilities[0].evidence.value == "foo"
8080

8181

8282
def test_nosamesite_cookies_other(iast_span_defaults):
@@ -89,7 +89,7 @@ def test_nosamesite_cookies_other(iast_span_defaults):
8989
assert len(vulnerabilities) == 1
9090

9191
assert vulnerabilities[0].type == VULN_NO_SAMESITE_COOKIE
92-
assert vulnerabilities[0].evidence.value == "foo=bar;secure;httponly;samesite=none"
92+
assert vulnerabilities[0].evidence.value == "foo"
9393

9494

9595
def test_nosamesite_cookies_lax_no_error(iast_span_defaults):

0 commit comments

Comments
 (0)