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

Buffer overflow in mg_resolve_from_hosts_file function #1140

Closed
BushraAloraini opened this issue Aug 20, 2020 · 1 comment
Closed

Buffer overflow in mg_resolve_from_hosts_file function #1140

BushraAloraini opened this issue Aug 20, 2020 · 1 comment

Comments

@BushraAloraini
Copy link

Buffer overflow in mg_resolve_from_hosts_file function (line 124) in mongoose/src/mg_resolv.c in Mongoose 6.18, where sscanf copies data from p to alias without limiting the size of the copied data not to exceed the alias array size, which is 256. Note that p can be up to 1024 (minus the IP digits) and is copied from a tainted file. This bug can be triggered by a malformed hosts file that includes a hostname that is larger than 256.

One way to fix this bug is by adding the format width specifier

for (p = line + len; sscanf(p, "%255ss%n", alias, &len) == 1; p += len) {

@cpq
Copy link
Member

cpq commented Dec 18, 2020

Closing this, as hosts file scanning has been removed from the latest codebase.

@cpq cpq closed this as completed Dec 18, 2020
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