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

Prevent panic on malformed auth data #557

Merged

Conversation

timvaillancourt
Copy link
Contributor

@timvaillancourt timvaillancourt commented Mar 29, 2021

This PR resolves a panic in readAuthData when the function receives malformed data:

panic: runtime error: index out of range [129] with length 129

This occurs when the pos integer passed to readAuthData is greater than the length of data

This is causing a panic/crash of a MySQL proxy that uses github.com/siddontang/go-mysql/server whenever a vulnerability scanning tool ("Nessus") tries to test CVE-2006-1516 against the MySQL port

I don't have the full context on the CVE or what Nessus is testing, but this fix ensures a ER_HANDSHAKE_ERROR is returned instead of a panic if the pos is greater than the length of the data slice

@timvaillancourt timvaillancourt changed the title Handle malformed data in readAuthData Prevent panic on malformed data in readAuthData Mar 29, 2021
@timvaillancourt timvaillancourt changed the title Prevent panic on malformed data in readAuthData Prevent panic on malformed auth data Mar 29, 2021
@atercattus atercattus self-assigned this May 27, 2021
@atercattus
Copy link
Member

We got the same panic in our production :)

@atercattus atercattus merged commit c327c53 into go-mysql-org:master May 27, 2021
@timvaillancourt timvaillancourt deleted the readAuthData-bad-handshake branch May 27, 2021 17:24
@timvaillancourt
Copy link
Contributor Author

Thanks @atercattus!

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

Successfully merging this pull request may close these issues.

2 participants