Browser/crypto base64 decoding strictly required padding #716
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.
Environment details
google-auth-library
version: 4.0.0Description
Browser implementation of crypto uses npm package
base64-js
to decode base64 strings. Base64-js package strictly requires padding on base64 strings, so when the base64 string is passed to the function the user is represented with an error "Can't parse token envelope".For an example OAuth2Client.verifyIdToken (internally calls verifySignedJwtWithCertsAsync) -method uses crypto to decode base64 strings. In this case when id_token is passed, the client implementation might raise an error for user if id_token segment 0 or 1 is non-modular with 4.
NodeJS implementation of crypto uses Buffers which is not strict with padding, so NodeJS implementation is working correctly.
There is an issue on base64-js Github repository issue tracker (beatgammit/base64-js#45), but the issue is quite old. It might be better for you guys to create a simple ADHoC fix for this (I can provide a PR) or change the base64 decoding library.
The text was updated successfully, but these errors were encountered: