From 130d728b9294f80d1ad618ad20aa0e62b6395289 Mon Sep 17 00:00:00 2001 From: Sarah Lacard Date: Fri, 1 May 2026 13:37:09 -0600 Subject: [PATCH 1/2] fix(detector): detect io stream output manipulation --- kernelguard.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernelguard.py b/kernelguard.py index f086847..fe3918f 100644 --- a/kernelguard.py +++ b/kernelguard.py @@ -3026,6 +3026,13 @@ def detect_precision_downgrade(code: str | SubmissionFacts) -> list[dict]: # --------------------------------------------------------------------------- +RE_IO_STREAM = re.compile(r'io\.(?:StringIO|BytesIO)\s*\(') +def detect_io_stream_output(code: str | SubmissionFacts) -> list[dict]: + facts = ensure_submission_facts(code) + if not RE_IO_STREAM.search(facts.raw_code): return [] + return [{"pattern": "STDIO_REDIRECT", "severity": "medium", "evidence": "io.StringIO/BytesIO — in-memory stream for output injection/manipulation"}] + + # Score anomaly detection # --------------------------------------------------------------------------- @@ -3790,6 +3797,7 @@ def support_only_patterns(matched_patterns: list[dict]) -> bool: detect_thread_injection, detect_lazy_tensor, detect_precision_downgrade, + detect_logging_output_injection, ] BASE_DETECTOR_SPECS = [ @@ -3827,6 +3835,7 @@ def support_only_patterns(matched_patterns: list[dict]) -> bool: ("thread_injection", detect_thread_injection), ("lazy_tensor", detect_lazy_tensor), ("precision_downgrade", detect_precision_downgrade), + ("io_stream_output", detect_io_stream_output), ] VALID_RULE_OUTCOMES = {AUTO_FILTER, SUSPICIOUS_ONLY, TELEMETRY_ONLY} From c70648ff4d0a346e464497dd566d93145b89e3ca Mon Sep 17 00:00:00 2001 From: Sarah Lacard Date: Fri, 1 May 2026 22:20:16 -0600 Subject: [PATCH 2/2] chore: trigger blue-pr-sync re-evaluation