Skip to content

cosign verify-attestation hangs indefinitely in GitHub Actions #3602

Closed as not planned

Description

@AliSajid

Description

I have a GitHub Action that builds and signs an image and pushes it to GHCR and DockerHub. I verify the signatures in the same action. The verification for the image happens instantly but on the Verify-Attestataion for the SBOM, it hangs until it times out in six hours. I can verify that the attestation is pushed to the container registries and I can verify that locally on my Mac (M2) painlessly.

I'm using syft for SBOM generation and right now using a practically empty Dockerfile.

Version

cosign: v2.2.3
syft: v1.0.1

These are the logs from an example run.
logs_21813240831.zip

The workflow is here: https://github.com/AliSajid/aaprop/blob/next/.github/workflows/build_container.yaml

Activity

  1. added
    bug
    on Mar 18, 2024
  2. Hayden-IO commented on Mar 19, 2024

    @Hayden-IO
    Contributor

    This sounds like a one-off GHA failure, is it still occurring?

  3. AliSajid commented on Mar 19, 2024

    @AliSajid
    Author

    This has been consistently occurring over the past ~3 days. Sometimes it succeeds, but with an inordinately long time. An example of a very long run before success is here.

    I have one action run happening right now which is going through the same process.

  4. ckotzbauer commented on May 9, 2024

    @ckotzbauer
    Contributor

    I can confirm the same behaviour in one of my actions.

  5. Hayden-IO commented on May 9, 2024

    @Hayden-IO
    Contributor

    Without logs, I'm unable to reproduce this.

  6. ckotzbauer commented on May 10, 2024

    @ckotzbauer
    Contributor

    I create a repro build and share it here.

  7. ckotzbauer commented on May 11, 2024

    @ckotzbauer
    Contributor

    I created a simple reproduction repository and the workflow hung on the first execution: https://github.com/ckotzbauer/verify-attestation-repro/actions/runs/9044178111/job/24852568726

    Between line 32 and 33/34 it took about 8 minutes.

  8. Hayden-IO commented on May 13, 2024

    @Hayden-IO
    Contributor

    At a quick glance, the large payload stands out to me. Will have to dig in a bit more.

  9. AliSajid commented on May 21, 2024

    @AliSajid
    Author

    Hi. This is still an issue. Thank you, @ckotzbauer, for making the reproducible repo. @haydentherapper The large payload seems typical for what I've been doing. I may be doing it wrong but I've been generally following standard advice. I will appreciate any help.

  10. jku commented on May 23, 2024

    @jku
    Member

    I have no idea yet why this would happen but I can confirm that PrintVerification() is fast locally but takes 8 minutes on GHA:

    https://github.com/jku/test-cosign-verify-hang/actions/runs/9204640839/job/25318590422

    EDIT:

    As far as I can tell it's literally the fmt.Println() for payload printing that takes forever. It seems really weird: the printed data is not amazing (a single line of 300k characters) but I wouldn't expect that to take minutes

  11. jku commented on May 23, 2024

    @jku
    Member

    We're likely hitting this: actions/runner#1031: the github runner is processing the line trying to find leaked secrets etc.

  12. jku commented on May 23, 2024

    @jku
    Member

    As a workaround for folks affected: Here's a version of @ckotzbauer's workflow that runs in 4 seconds:
    https://github.com/jku/test-cosign-verify-hang/blob/d6cddde9fa39d497e45ba86b3cbedfd3c07b0c55/.github/workflows/test.yml

    • just redirecting STDOUT is enough to make it quick
    • actions/upload-artifact is added to make sure the output is still available if needed
  13. ckotzbauer commented on May 23, 2024

    @ckotzbauer
    Contributor

    @jku Thanks for the workaround and some further analysis, much appreciated! 🎉

  14. AliSajid commented on May 23, 2024

    @AliSajid
    Author

    @jku Thank you so much. I did not even think of that being an issue. I hope GitHub fixes that. Meanwhile, I'll use the work around.

  15. lcarva commented on May 30, 2024

    @lcarva
    Contributor

    Printing the payload is critical for use cases where the content of the attestation matters. For example, it is common to associate an SBOM to an image as an attestation. cosign verify-attestation is how one would securely fetch those SBOMs. Changing the command to no longer print the payload would be problematic.

    Redirecting as @jku mentioned seems like a good solution.

    In cases where redirecting output is not possible, one could use the --output-file flag to save the payload to a file instead of printing it to stdout.

  16. jku commented on May 30, 2024

    @jku
    Member

    Redirecting as @jku mentioned seems like a good solution.

    It's pretty bad UX though if verify-attestation can take tens of minutes by default and the user needs to find these workarounds to get it to operate in reasonable time... but yes, just documenting this is an option.

  17. AliSajid commented on May 30, 2024

    @AliSajid
    Author

    I'm wondering if we can wrap this into a separate GitHub action that does that transparently without user intervention.

  18. ckotzbauer commented on May 30, 2024

    @ckotzbauer
    Contributor

    Maybe adding a new cli-option to opt-out of the payload-printing would be an option?

  19. AliSajid commented on Aug 5, 2024

    @AliSajid
    Author

    Maybe adding a new cli-option to opt-out of the payload-printing would be an option?

    An option like --quiet would be appreciated.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions