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

Incomplete regular expression WORKFORCE_AUDIENCE_PATTERN #1385

Closed
hankei6km opened this issue Mar 24, 2022 · 1 comment · Fixed by #1654
Closed

Incomplete regular expression WORKFORCE_AUDIENCE_PATTERN #1385

hankei6km opened this issue Mar 24, 2022 · 1 comment · Fixed by #1654
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@hankei6km
Copy link

My repository( (hankei6km/gdrive-act-share ) contains the code that bundles googleapis/google-auth-library-nodejs. And my repositry is enabled CodeQL.

CodeQL has detected that it has not escaped the meta-character.

This string, which is used as a regular expression here, has an unescaped '.' before 'googleapis.com/locations/', so it might match more hosts than expected.

const WORKFORCE_AUDIENCE_PATTERN =
'//iam.googleapis.com/locations/[^/]+/workforcePools/[^/]+/providers/.+';

Environment details

  • OS: Docker Container(mcr.microsoft.com/vscode/devcontainers/typescript-node:16-bullseye)
  • Node.js version: v16.14.0
  • npm version: 8.3.1
  • google-auth-library version: google-auth-library@7.14.0

Steps to reproduce

I checked it in the cloned repository.

I Added //iam.googleapisXcom/locations/global/workforcePools/workloadPools/providers/oidc to this test.

it('should not throw on valid service account impersonation url', () => {

})

https://github.com/hankei6km/test-google-auth-library-nodejs/blob/b5f091b2b304645e7039e6eb778130ad88fb6842/test/test.baseexternalclient.ts#L285-L286

It was not thrown.

https://github.com/hankei6km/test-google-auth-library-nodejs/runs/5672358984?check_suite_focus=true#step:8:820

After fixing it, it was thrown.

const WORKFORCE_AUDIENCE_PATTERN =
  '//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+';

https://github.com/hankei6km/test-google-auth-library-nodejs/blob/7fd8372539d77c69552848c1e3e95d76d44a8e30/src/auth/baseexternalclient.ts#L60-L62

@hankei6km hankei6km added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 24, 2022
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Jun 22, 2022
@danielbankhead
Copy link
Member

Thanks for filing! I've created a PR to resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@hankei6km @danielbankhead @yoshi-automation and others