From 7e06c4074ec871196513e116b14cfd138541e9f1 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Mon, 16 Nov 2026 11:11:36 -0800 Subject: [PATCH 1/2] fix(validators): stop the version-label regex stalling the PII scan on long identifiers When the PII scan finds an IPv4-shaped value it looks for a version label in the 80 characters before it. The label pattern described the camel-case words around the label as a repeated word group, and a run of letters can be split into such words in exponentially many ways. A 24-letter name before the value took 0.6 seconds to scan, and every further letter roughly doubled that. Each repeated group is now a single run that matches the same strings. The old and new patterns give the same matches on 2.8 million test strings. A new test scans long identifiers in a subprocess with a time limit and checks the findings are unchanged. Signed-off-by: Christopher Kevin --- CHANGELOG.md | 2 ++ src/skillevaluator/validators/security.py | 10 ++++--- tests/validators/test_security.py | 32 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cc85b538..f04a96139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -411,6 +411,8 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed +- The Tier 1 PII scan no longer stalls on a long identifier before an IPv4-shaped value. A line with a + 30-letter name followed by `= "8.8.0.8"` took about a minute to scan, and every further letter doubled that. - Keep Steps per Eval Case chart labels readable for long case IDs while preserving full IDs in hover tooltips. - Negative controls with complete, confirmed skill non-use report wrong answers as task outcomes instead of recommending skill edits; truncated or recovered attempt evidence cannot establish complete non-use. - Repeated negative-case task outcomes share one advice item, retain task-failure wording and avoid describing passing attempts as lost, keeping distinct skill fixes visible. diff --git a/src/skillevaluator/validators/security.py b/src/skillevaluator/validators/security.py index 0ab869198..feebf9b19 100644 --- a/src/skillevaluator/validators/security.py +++ b/src/skillevaluator/validators/security.py @@ -6110,13 +6110,17 @@ def _is_personal_home_path(self, match: re.Match, protected_usernames: set[str]) ) # Match version/tag as identifier tokens, including separator and camel-case styles. # Plain substrings such as ``conversion`` and ``staging`` are not version labels. + # The camel-case words around the label are written as one run each + # (``[A-Z][A-Za-z0-9]*``), not as a repeated word group: a repeated group can + # split a run of letters in exponentially many ways, and a long identifier + # before an IPv4-shaped value then stalls the scan. _VERSION_LABEL_PATTERN = re.compile( r"(?:" r"(?i:(? assert not any(finding.check_name == "ip_addresses" for finding in result.findings) + def test_long_identifiers_before_ip_values_do_not_stall_the_scan(self, tmp_path: Path) -> None: + """Regression (CWE-1333): the version-label pattern could split a run of letters in exponentially many + ways, so a 30-letter identifier before an IPv4-shaped value stalled the PII scan for about a minute and + every further letter doubled that. Runs in a subprocess so that a slow scan fails the timeout instead of + hanging the suite; the limit is generous because the scan takes about a second.""" + skill_dir = tmp_path / "long-identifier-skill" + skill_dir.mkdir() + not_labels = ["a" * 76, "A" * 76, "aB" * 38, "a1" * 38] + labels = ["a" * 69 + "Version", "version" + "A" * 69, "Tag" + "Ab1" * 24, "a" * 60 + "_version"] + (skill_dir / "SKILL.md").write_text( + "".join(f'{name} = "8.8.0.{index}"\n' for index, name in enumerate(not_labels, 1)) + + "".join(f'{name} = "4.4.0.{index}"\n' for index, name in enumerate(labels, 1)), + encoding="utf-8", + ) + code = ( + "import json, sys\n" + "from pathlib import Path\n" + "from skillevaluator.validators.security import SecurityValidator\n" + "result = SecurityValidator().validate_pii_only(Path(sys.argv[1]))\n" + "found = {f.metadata.get('matched_value') for f in result.findings if f.check_name == 'ip_addresses'}\n" + "print(json.dumps(sorted(found)))\n" + ) + + completed = subprocess.run( + [sys.executable, "-c", code, str(skill_dir)], capture_output=True, text=True, timeout=60 + ) + + assert completed.returncode == 0, completed.stderr + # The long plain identifiers are not version labels, so their values are still reported; + # the long labels still mark theirs as release versions. + assert json.loads(completed.stdout) == ["8.8.0.1", "8.8.0.2", "8.8.0.3", "8.8.0.4"] + @pytest.mark.parametrize( "line", [ From c7c2395411e7f4c0cf930befa2780fe2c9bbf891 Mon Sep 17 00:00:00 2001 From: Christopher Kevin Date: Mon, 16 Nov 2026 11:22:56 -0800 Subject: [PATCH 2/2] test: bind PII scan regression to its checkout Signed-off-by: Christopher Kevin --- tests/validators/test_security.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/validators/test_security.py b/tests/validators/test_security.py index c2ab5acc5..4b7a7a343 100644 --- a/tests/validators/test_security.py +++ b/tests/validators/test_security.py @@ -8627,8 +8627,10 @@ def test_long_identifiers_before_ip_values_do_not_stall_the_scan(self, tmp_path: + "".join(f'{name} = "4.4.0.{index}"\n' for index, name in enumerate(labels, 1)), encoding="utf-8", ) + # Keep the child on this checkout even if its interpreter has another editable install. code = ( "import json, sys\n" + f"sys.path.insert(0, {str(Path(__file__).resolve().parents[2] / 'src')!r})\n" "from pathlib import Path\n" "from skillevaluator.validators.security import SecurityValidator\n" "result = SecurityValidator().validate_pii_only(Path(sys.argv[1]))\n"