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

extractAccessKey method exposes secrets in debug mode #60

Open
heurtematte opened this issue Aug 5, 2024 · 2 comments
Open

extractAccessKey method exposes secrets in debug mode #60

heurtematte opened this issue Aug 5, 2024 · 2 comments

Comments

@heurtematte
Copy link

Setting script to debug mode exposes secrets in logs.

  script:
    - set -x
    - !reference [.injectDevelocityForMaven]

Root cause:

  • method extractAccessKey
 key="${allKeys#*$hostname=}"    # Remove everything before the host name and '='

Avoid string manipulation with secrets.

Logs:

++ extractAccessKey [MASKED] develocity-staging.eclipse.org
+++ local allKeys=[MASKED]
+++ local hostname=develocity-staging.eclipse.org
+++ key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+++ '[' XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX == [MASKED] ']'
+++ key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX is exposed.

@heurtematte heurtematte changed the title extractAccessKey method expose secrets in debug mode extractAccessKey method exposes secrets in debug mode Aug 5, 2024
@alextu
Copy link
Member

alextu commented Aug 6, 2024

I see, although it seems like a GitLab limitation with masking variables. I guess we could implement an additional safety net like https://stackoverflow.com/a/48019999 but it seems a bit tedious and error prone (easy to forget portions of code) 🤔. Do you see another solution?

@heurtematte
Copy link
Author

heurtematte commented Aug 7, 2024

This is at least a nice workaround at the moment.

For future use, I would suggest to prefix all token. In gitlab pattern like glpat- are automatically masked.

Gitlab seems to have this feature: CI_TOKEN_MASK_PREFIXES, according to this MR https://gitlab.com/gitlab-org/gitlab/-/merge_requests/100882, but I have never been able to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants