Skip to content

Cosign CLI wrapper uses temp files and exec without input validation #106

Open

Description

@shieldx-bot

Description: shared/shieldx-common/pkg/policy/cosigncli.go writes digest/sig into temporary files and shells out to cosign. If the cosign binary path is attacker-controlled or PATH manipulated, this can lead to arbitrary command execution or use of a malicious cosign. Temp files are created in default temp dir and removed, but race conditions or broad perms may allow attackers to interfere.
Location: shared/shieldx-common/pkg/policy/cosigncli.go (functions Sign, Verify).
Recommendation: Validate c.Path (absolute path whitelist) or use a bundled cosign binary with fixed path. Use open file descriptors with secure permissions (0600) and avoid exposing predictable temp names. Where possible, replace exec-of-external-binary with in-process verification library (go-containerregistry/cosign). Add CI checks for PATH injection scenarios.
Done when: Cosign invocation uses an audited path or in-process library; temp files are created with secure perms and path collision/test cases are added.

Activity

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

    help wantedExtra attention is neededsecuritysystem security vulnerabilities

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions