@@ -385,22 +385,23 @@ def _decoded_shell_literal_payloads(content: str) -> list[tuple[int, str]]:
385385SC3_PATTERNS = SC3_CODE_PATTERNS + SC3_PROSE_PATTERNS
386386# Shell decode-to-execute chains run on every file type, like SC2, because
387387# SKILL.md instructions and hook configs carry shell commands too.
388+ # These two exact rules retain the audited bounded native path. Additional
389+ # shell rules default to the interruptible matcher until separately reviewed.
390+ _SC3_BOUNDED_PIPE_PATTERN = (
391+ rf"{ _SC3_SHELL_DECODER } (?:{ _SC3_HERE_STRING } \\?['\"]?"
392+ rf"[A-Za-z0-9+/=]{{0,{ _MAX_SHELL_LITERAL_CHARS } }}+)?+{ _SC3_PIPE_SEGMENT } "
393+ rf"(?:\|(?!\|)&?{ _SC3_PIPE_SEGMENT } ){{0,3}}?{ _SC3_PIPE_EXECUTOR } "
394+ )
395+ _SC3_BOUNDED_SUBSTITUTION_PATTERN = (
396+ rf"{ _SC3_SUBSTITUTION_EXECUTOR } [^()`\n]{{0,{ _MAX_SHELL_LITERAL_CHARS } }}?"
397+ rf"{ _SC3_SHELL_DECODER } "
398+ )
388399SC3_SHELL_PATTERNS = [
389- (
390- # A here-string literal can outgrow a pipeline stage, so it is consumed
391- # whole, and possessively, before the first stage.
392- rf"{ _SC3_SHELL_DECODER } (?:{ _SC3_HERE_STRING } \\?['\"]?"
393- rf"[A-Za-z0-9+/=]{{0,{ _MAX_SHELL_LITERAL_CHARS } }}+)?+{ _SC3_PIPE_SEGMENT } "
394- rf"(?:\|(?!\|)&?{ _SC3_PIPE_SEGMENT } ){{0,3}}?{ _SC3_PIPE_EXECUTOR } " ,
395- 0.9 ,
396- ),
397- (
398- rf"{ _SC3_SUBSTITUTION_EXECUTOR } [^()`\n]{{0,{ _MAX_SHELL_LITERAL_CHARS } }}?"
399- rf"{ _SC3_SHELL_DECODER } " ,
400- 0.9 ,
401- ),
400+ (_SC3_BOUNDED_PIPE_PATTERN , 0.9 ),
401+ (_SC3_BOUNDED_SUBSTITUTION_PATTERN , 0.9 ),
402402]
403403
404+
404405# SC7: Untrusted Container Image — pulling images with signature/registry
405406# verification turned off. These flags disable image trust regardless of the
406407# registry, so they are a strong supply-chain signal with near-zero FP.
@@ -2287,7 +2288,7 @@ def line_number(start: int) -> int:
22872288 # the interruptible engine adds enough cost to reject dense input.
22882289 matches = (
22892290 re .finditer
2290- if ( pattern , confidence ) in SC3_SHELL_PATTERNS
2291+ if pattern in ( _SC3_BOUNDED_PIPE_PATTERN , _SC3_BOUNDED_SUBSTITUTION_PATTERN )
22912292 else static_runner .iter_paragraph_matches
22922293 if (pattern , confidence ) in SC3_PROSE_PATTERNS
22932294 else static_runner .iter_pattern_matches
0 commit comments