Skip to content

Refraction JCL forge: EXEC CICS/SQL counts wrong and the unbounded lazy regex runs over the whole joined file #3205

Closed

Description

@squid-protocol

Found by the #3120 differential; the ReDoS shape was already cited in #3120's "discipline asymmetry" section.

analyze_cobol_intent (gitgalaxy/tools/cobol_to_cobol/cobol_jcl_forge.py) joins the whole file into one string and runs:

cics_matches = re.findall(r"EXEC\s+CICS.*?END-EXEC\.", monolith_code, re.IGNORECASE)
sql_matches  = re.findall(r"EXEC\s+SQL.*?END-EXEC\.",  monolith_code, re.IGNORECASE)

Two problems

  1. The counts are wrong. The pattern requires a period right after END-EXEC, but inside an IF/EVALUATE a block ends END-EXEC with no period. The lazy .*? then runs on to the next END-EXEC. and swallows every block in between. Measured on CBSA against a line-level EXEC CICS count:

    program cics_calls actual
    BNKMENU 6 62
    XFRFUN 9 77
    BNK1CAC 9 37

    The is_cics / is_db2 booleans are correct on all 36 programs, and only the booleans reach generated JCL. The counts are printed by the standalone CLI.

  2. Unbounded lazy quantifier over a whole-file string. This is the shape how_to_add_a_language.md Rule 5 forbids for engine rules. The forge patterns get no ReDoS audit.

Fix

Count per statement instead of across the joined string. For example, match EXEC\s+CICS\b on the normalised lines, or bound the body ([^.]{0,N}?END-EXEC). Put the pattern under the same ReDoS sweep the engine uses. The engine's hit columns can't substitute: arch_io / arch_ipc mix CICS verbs, SQL, DLI and CALL (docs/refraction_engine_differential.md D4, PR for #3120).

Activity

  1. added
    bug
    legacy-modernization
    security
    on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy-modernizationsecurity

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions