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

fix: check directory traversal attack without file system visit #473

Merged
merged 1 commit into from
Apr 25, 2020
Merged

fix: check directory traversal attack without file system visit #473

merged 1 commit into from
Apr 25, 2020

Conversation

DCjanus
Copy link
Contributor

@DCjanus DCjanus commented Apr 25, 2020

We don't want to leak information of which files exist to adversaries, but the origin version of ServeDir did.

We are using canonicalize to make sure file_path is simple, but, unfortunately, it would visit file system, which might be slow, and attackers could count the time that server response, with hundreds of requests, attacker would know which file is exists even it is not sub path of root.

read more: https://en.wikipedia.org/wiki/Timing_attack

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great; thanks heaps!

}
log::info!("Requested file: {:?}", dir);

log::info!("Requested file: {:?}", file_path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we could warn here with the full requested path if it contained a .. instead.

@yoshuawuyts yoshuawuyts merged commit 28e5904 into http-rs:master Apr 25, 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

Successfully merging this pull request may close these issues.

2 participants