Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Subject exceeds the 127 byte limit mitigation strategy #423

Closed
reakaleek opened this issue Jun 25, 2024 · 4 comments
Closed

Docs: Subject exceeds the 127 byte limit mitigation strategy #423

reakaleek opened this issue Jun 25, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@reakaleek
Copy link

TL;DR

The troubleshooting guide suggests that you can only use shorter repo or branch names to overcome the 127-byte limit issue.

But you can also adjust the attribute mapping and shorten the subject.

Detailed design

You can overcome the 127 byte limit by shortening the google.subject in the attribute mapping.

gcloud iam workload-identity-pools providers create-oidc "my-repo" \
  --project="${PROJECT_ID}" \
  --location="global" \
  --workload-identity-pool="github" \
  --display-name="My GitHub repo Provider" \
-  --attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.repository=assertion.repository,attribute.repository_owner=assertion.repository_owner" \
+  --attribute-mapping="google.subject=assertion.sub.split(':')[1],attribute.actor=assertion.actor,attribute.repository=assertion.repository,attribute.repository_owner=assertion.repository_owner" \
  --attribute-condition="assertion.repository_owner == '${GITHUB_ORG}'" \
  --issuer-uri="https://token.actions.githubusercontent.com"

Hence, in cases where the sub claim is repo:<orgName/repoName>:pull_request it will be change to <orgName/repoName>, which will shorten the google.subject to some degree.

Update documentation accordingly.

Additional information

No response

@reakaleek reakaleek added the enhancement New feature or request label Jun 25, 2024
Copy link

Hi there @reakaleek 👋!

Thank you for opening an issue. Our team will triage this as soon as we can. Please take a moment to review the troubleshooting steps which lists common error messages and their resolution steps.

@sethvargo
Copy link
Member

Sure, but that same value (<orgName/repoName>) is available via assertion.repository without any string manipulation. It also greatly reduces the subject granularity, which would not be advised. As such, I'm not comfortable with even documenting this option, since unfamiliar users could too-easily misconfigure access.

@sethvargo sethvargo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
@reakaleek
Copy link
Author

reakaleek commented Jun 26, 2024

@sethvargo thank you for the feedback.

Would you mind explaining why a reduced subject granularity is not advised?

Context:

Due to the quirks of AWS OIDC authentication, we had to modify the sub claim for the GH repository to include more attributes.
This broke the google auth because of the 127 byte limit.

So, do you think it's okay to shorten the google.subject if we still use other attributes in the condition?

I want to understand the implications of this and if I should reconsider my approach.

@sethvargo
Copy link
Member

The subject (sub) is an unique identifier of the user, device, or application, idempotently consistent for the same inputs. “sub” is a standard claim representing the entity to which the token is issued. If you change the subject to be overly broad, it no longer uniquely represents the invocation, which can lead to easy misconfigurations downstream that grant overzealous permissions to a broad set of workflows and repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants