Skip to content

fix(config): devops config audit-keys does not find a plaintext secret under a nested key such as service.github_app.private_key #2511

Closed

Description

@dan-petty

Problem Description

devops config audit-keys does not find a plaintext secret under a key that has more than two levels. commands/config.py::_scan_yaml_for_secret_keys examines only <section>.<option>. The managed credential service.github_app.private_key has three levels, so the audit does not examine it in any config file that it scans.

The settings load ignores the value, because GitHubAppConfig has extra='ignore'. But the plaintext private key stays on disk, and the audit reports the config compliant. The help of the command says that it exits 1 when a config file holds a plaintext secret. That is false for this key.

Reproduction Steps

  1. Make a temporary HOME. Write service:, github_app: and private_key: FAKE-PEM-0123 to $HOME/.config/devops-cli/config.yaml.
  2. Write log_level: INFO to a clean file, and set DEVOPS_CLI_CONFIG to that file.
  3. Set PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring.
  4. Run devops config audit-keys --json.

The same result occurs when the active config file holds the key, because the scanner is the same for each file.

Expected vs Actual Behavior

Expected: the report lists the leak of service.github_app.private_key under plaintext_leaks, is_compliant is false, and the command exits 1. The scanner examines each managed credential at its full dotted key (secret_keys()), at each depth.

Actual: the command exits 0 with is_compliant: true and plaintext_leaks: [].

Environment Diagnostics

devops-cli 0.10.0, source at origin/main 0137f23 and on the branch of #2426. PyYAML 6.0.3, Python 3.14.10, Linux.

Logs, Traces, or Terminal Output

{'scanned_config_files': ['<tmp>/.config/devops-cli/config.yaml', '<tmp>/proj/clean.yaml'], 'plaintext_leaks': [], 'is_compliant': True, 'unaudited_config_files': []}
exit=0

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #2426

Proposed design

Problem statement

The devops config audit-keys command reports a config file as compliant when it holds a plaintext secret under a key deeper than two levels. The scanner _scan_yaml_for_secret_keys in commands/config.py examines only . pairs. The managed credential service.github_app.private_key has three levels, so the scanner never checks it. The command exits 0 and reports is_compliant: true even though a plaintext private key is on disk.

Acceptance criteria

Requirement: Detect secret at any depth

The scanner SHALL detect a plaintext secret value at any nesting depth in a YAML config file.

Scenario: Three-level key holds a plaintext value

  • WHEN A config file contains service.github_app.private_key set to a non-empty string that is not a keyring reference
  • THEN The report lists service.github_app.private_key under plaintext_leaks

Requirement: Compliance flag is false on leak

The report SHALL set is_compliant to false when any plaintext leak is found.

Scenario: One leak present

  • WHEN The scanner finds one or more plaintext leaks in any scanned file
  • THEN is_compliant is false in the JSON report

Requirement: Exit code 1 on leak

The command SHALL exit with code 1 when a plaintext leak is found.

Scenario: Leak detected in active config

  • WHEN The scanner reports at least one entry in plaintext_leaks
  • THEN The process exit code is 1

Requirement: Use secret_keys registry

The scanner SHALL use the secret_keys() registry as the source of truth for which dotted keys to check.

Scenario: Registry key at depth three is checked

  • WHEN secret_keys() returns service.github_app.private_key and the config file holds that key with a plaintext value
  • THEN The scanner navigates the parsed YAML by splitting the key on . and reports the value as a leak

Requirement: Two-level keys still detected

The scanner SHALL continue to detect plaintext secrets at two-level keys such as grafana.token.

Scenario: Two-level key holds a plaintext value

  • WHEN A config file contains grafana.token set to a non-empty string that is not a keyring reference
  • THEN The report lists grafana.token under plaintext_leaks

Existing Tool Considered

The project's own scanner _scan_yaml_for_secret_keys in commands/config.py covers the need. It lacks correct traversal for keys deeper than two levels. The fix modifies the existing iteration loop to navigate each secret key from secret_keys() at its full dotted path. No new library is added. The cost is the tokens to change the loop and add one test for a three-level key, plus the time to run the test suite.

Key questions

  • What is the source of truth for which dotted keys are managed secrets?: The secret_keys() registry in the settings module. It returns the full dotted path of every managed credential, including service.github_app.private_key. [sources: src/devops_cli/config/settings.py:789, src/devops_cli/config/settings.py:829]
  • How should the scanner traverse the parsed YAML to find a secret key at any depth?: For each key in secret_keys(), split the dotted path on . and navigate the parsed dict step by step. If the final value is a non-empty string that is not a keyring reference, report it as a plaintext leak. This replaces the current two-level loop. (proposed)
    • Chosen: Split-and-navigate each secret key. Uses the registry as the single source of truth. Handles any depth. Minimal change to the existing loop. Chosen.
    • Rejected: Flatten the YAML to all dotted paths and check membership. Builds a full path list for every key in the file, then intersects with the registry. More work per file and does not scale if the file is large. Rejected.
    • Rejected: Recursively walk the dict and match leaf names. Matches on the last segment of the path only, which can produce false positives when two sections share a leaf name. Rejected.

Open questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-04: partly.
Tool: Yelp/detect-secrets (https://github.com/Yelp/detect-secrets), Apache-2.0, last activity 2026-04-02, maintained.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The scanner misses a known secret key because it only checks two-level dotted keys.
    • Priority: P2-Medium. A security audit reports compliant when a plaintext secret is present, but the gap is limited to one three-level key.
    • Value: Medium. Users who rely on audit-keys for compliance get a false pass for one credential path.
    • Effort: Low. The fix changes the scan loop to walk keys at every depth instead of hard-coding two levels.
    • Related: fix(config): the secrets audit never prints a config line it cannot parse, and an unparsable file is not reported clean #1022, which asks for a different change. Both target _scan_yaml_for_secret_keys in config.py, but #1022 fixes a parse-error path while the candidate fixes the key-depth scan.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 0f7bc26 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

  5. added
    scope/config
    on Oct 30, 2026
  6. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Tool: Yelp/detect-secrets (https://github.com/Yelp/detect-secrets)

    • License: Apache-2.0
    • Last activity: 2026-04-02
    • Maintained: yes

    Covers:

    • Scans YAML files for plaintext secrets and private keys without depending on the nesting depth of the key
    • Ships private-key and keyword based detectors that can flag a private_key value that is stored in the clear
    • Reports findings as machine-readable output that a CI or audit step can act on

    Lacks:

    • Does not use the project's secret_keys() registry as the source of truth for which dotted keys are managed credentials
    • Has no notion of a keyring reference, so it cannot tell a keyring reference from a plaintext value the way the audit must
    • Does not produce the devops config audit-keys report fields (plaintext_leaks, is_compliant, unaudited_config_files) or the command's exit code
    • Detects by content heuristics rather than by resolving a full dotted path such as service.github_app.private_key, so a fake/non-PEM value could be missed

    Searches run:

    • python library scan YAML config file for plaintext secrets nested keys
    • detect-secrets YAML plugin nested keys keyring reference detection

    Sources:

    Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    owner/agent
    status/in-review
    and removed
    status/new
    on Nov 4, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 4, 2026
  9. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-05 00:12 UTC

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

    effort/lowpriority/p2-mediumscope/configsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions