T09 · Insecure Skill Coding Practices
- Location
scripts/oidc-hardening-audit.sh:102- Finding
Workflow-Wide Regex Checks Can Miss Insecure Job-Level OIDC Configurations
- Content
View full analysis
Vulnerability Details
File Location:
scripts/oidc-hardening-audit.sh, lines 102–103, 139–140, and 165–176
Vulnerability Type: Incorrect security validation caused by unscoped text matching
Risk Level: MediumVulnerable code:
python perm_id_token_write_re = re.compile(r"^\s*id-token\s*:\s*write\s*(?:#.*)?$", re.IGNORECASE | re.MULTILINE) role_to_assume_re = re.compile(r"^\s*role-to-assume\s*:\s*[^\s#]+")python lines = text.splitlines() has_id_token_write = bool(perm_id_token_write_re.search(text)) auth_actions = [] floating_refs = [] aws_action_lines = set() aws_role_to_assume_present = False aws_static_input_present = False secret_cloud_key_lines = []python if not has_id_token_write: score += 4 issues.append({ 'code': 'missing_id_token_write', 'message': 'Workflow uses cloud auth action(s) but does not declare id-token: write permissions.', 'weight': 4, }) if any(action['provider'] == 'aws' for action in auth_actions): if not aws_role_to_assume_present: score += 2 issues.append({ 'code': 'aws_role_to_assume_missing', 'message': 'AWS auth action is present but role-to-assume is missing (OIDC federation likely incomplete).', 'weight': 2, })Technical Analysis
The scanner analyzes each workflow as unstructured text rather than parsing its YAML hierarchy. The
has_id_token_writeandaws_role_to_assume_presentvariables therefore represent whether matching text appears anywhere in the file, not whether the setting applies to the job or authentication step being audited.GitHub Actions supports workflow-level and job-level permissions. A job-level
permissionsblock can override workflow-level permissions. Consequently, anid-token: writedeclaration in one job, or at workflow level when overridden by the cloud-authentication jo ...[truncated 1851 chars]- Remediation
View remediation
Remediation Suggestions
- Replace regex-based workflow interpretation with structural YAML parsing through a safe loader.
- Analyze every
jobs.<job_id>object independently and associate each cloud authentication action with its containing job and exact step. - Resolve effective permissions according to GitHub Actions semantics:
- Read workflow-level permissions.
- Apply job-level permission overrides.
- Verify that the specific cloud-authentication job has effective
id-token: write.
- Inspect
role-to-assume, static credential inputs, and provider-specific options only within thewithmapping of the corresponding authentication step. - Do not count matching strings found in comments, shell commands, environment values, or YAML block scalars as configuration.
- Add regression tests covering multiple jobs, job-level permission overrides, unrelated
role-to-assumefields, YAML block scalars, and multiple AWS authentication steps with different configurations. - Fail safely or emit an explicit parse error when a workflow cannot be structurally parsed, rather than deriving security conclusions from partial text matches.
