Skip to content

Commit 560c47f

Browse files
committed
✅ add tests for GHSA-2026 comma array limit handling
1 parent 77fac3c commit 560c47f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/unit/decode_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,3 +1733,26 @@ def test_array_limit_checks(self) -> None:
17331733
def test_no_limit_does_not_overflow(self) -> None:
17341734
# Verify that within limit it stays a list
17351735
assert decode("a[]=b&a[]=c", DecodeOptions(list_limit=2)) == {"a": ["b", "c"]}
1736+
1737+
1738+
class TestGHSA2026CommaArrayLimit:
1739+
def test_ghsa_w7fw_comma_poc_raises_when_limit_exceeded(self) -> None:
1740+
# GHSA-w7fw-mjwx-w883 / CVE-2026-2391 PoC shape (comma parsing + list limit bypass attempt)
1741+
# Upstream fixed in qs v6.14.2.
1742+
query = "a=" + ("," * 25) # 26 items after split
1743+
1744+
with pytest.raises(ValueError, match="List limit exceeded"):
1745+
decode(
1746+
query,
1747+
DecodeOptions(comma=True, list_limit=5, raise_on_limit_exceeded=True),
1748+
)
1749+
1750+
def test_ghsa_w7fw_comma_at_limit_does_not_raise(self) -> None:
1751+
# Control case for the same GHSA path: exactly at list_limit should parse successfully.
1752+
# Matches the strict limit semantics preserved in this port.
1753+
result = decode(
1754+
"a=1,2,3,4,5",
1755+
DecodeOptions(comma=True, list_limit=5, raise_on_limit_exceeded=True),
1756+
)
1757+
1758+
assert result == {"a": ["1", "2", "3", "4", "5"]}

0 commit comments

Comments
 (0)