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

Unnecessary custom base64 implementation #5

Open
joonas-fi opened this issue Mar 3, 2021 · 2 comments
Open

Unnecessary custom base64 implementation #5

joonas-fi opened this issue Mar 3, 2021 · 2 comments

Comments

@joonas-fi
Copy link

Go has RawStdEncoding which makes this unnecessary:

jwt/token.go

Line 247 in 1639fcf

func Base64Encode(src []byte) []byte {

Not trying to nitpick here, rather I think security-wise it's dangerous as a concept to mutate untrusted input data before it's fed to a signature validation algorithm

@joonas-fi
Copy link
Author

If you're open to more suggestions:

jwt/util.go

Line 6 in 1639fcf

func BytesToString(b []byte) string {

I think Go has recently done some optimizations where the compiler automatically optimizes these. I feel a bit unsafe with unsafe and doing special tricks in a security-critical library

@kataras
Copy link
Owner

kataras commented Apr 9, 2022

Hello @joonas-fi,

BytesToString and Base64Encode are mostly helpers for users of this package. BytesToString is used just on a single return statement, inside the blockfile.go file, of course we can remove it from there if that's a "security" issue for you, I can live without it too. Base64Encode is used one "encodeToken" just to encode server-side data, the custom claims you/your program provides and NOT the user/client's one - I don't see any security-wise issue here but I am open for further discussion.

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