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

[Bug] Decode URL Safe Base64 in Shadowsocks share link #38

Open
ricky9w opened this issue Dec 14, 2024 · 0 comments
Open

[Bug] Decode URL Safe Base64 in Shadowsocks share link #38

ricky9w opened this issue Dec 14, 2024 · 0 comments

Comments

@ricky9w
Copy link

ricky9w commented Dec 14, 2024

Commit d2f1118

Cannot correctly process URL Safe Base64 encoded user info (aka method:password) fields if the length of encoded field is not a multiple of 4.

The decodeBase64URLSafe function in the current code does not use = to fill the string length to a multiple of 4 and then hands the string to the base64 library for parsing:

func decodeBase64URLSafe(content string) (string, error) {
	content = strings.ReplaceAll(content, " ", "-")
	content = strings.ReplaceAll(content, "/", "_")
	content = strings.ReplaceAll(content, "+", "-")
	content = strings.ReplaceAll(content, "=", "")
	result, err := base64.StdEncoding.DecodeString(content)
	return string(result), err
}

https://github.com/ricky9w/serenity/blob/474ab7e4299d1395cf790036a07ecee23612599c/subscription/parser/raw.go#L37C1-L44C2

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

1 participant