Rocket/codegen/tests/run-pass
Sergio Benitez 4bc5c20a45 Fix security checks in `PathBuf::FromSegments`.
In #134, @tunz discovered that Rocket does not properly prevent path traversal
or local file inclusion attacks. The issue is caused by a failure to check for
some dangerous characters after decoding. In this case, the path separator '/'
was left as-is after decoding. As such, an attacker could construct a path with
containing any number of `..%2f..` sequences to traverse the file system.

This commit resolves the issue by ensuring that the decoded segment does not
contains any `/` characters. It further hardens the `FromSegments`
implementation by checking for additional risky characters: ':', '>', '<' as the
last character, and '\' on Windows. This is in addition to the already present
checks for '.' and '*' as the first character.

The behavior for a failing check has also changed. Previously, Rocket would skip
segments that contained illegal characters. In this commit, the implementation
instead return an error.

The `Error` type of the `PathBuf::FromSegment` implementations was changed to a
new `SegmentError` type that indicates the condition that failed.

Closes #134.
2017-01-13 13:25:33 -08:00
..
complete-decorator.rs URI uses Cow iternally. 2016-12-21 00:09:22 -08:00
custom-content-type.rs Warn, but don't error, on unknown route formats. 2016-12-27 15:30:33 -06:00
derive_form.rs Ignore _method field in derived FromForm. 2016-12-26 02:41:57 -06:00
dynamic-paths.rs Add more codegen tests. 2016-09-28 20:39:14 -07:00
empty-fn.rs Allow head decorator and options via route decorator. 2016-12-30 01:41:46 -06:00
empty_form.rs Remove non-streaming requests. Use streaming requests everywhere. 2016-10-12 00:14:42 -07:00
error-handler.rs Completely new raw API. 2016-10-07 23:20:49 -07:00
issue-1-colliding-names.rs Renamed macros to codegen. 2016-09-08 20:38:58 -07:00
methods.rs Test methods via route attribute. 2016-12-30 01:46:47 -06:00
rank_decorator.rs Allow different lifetimes in handler Request reference and its contents. 2016-10-06 20:38:13 -07:00
segments.rs Fix security checks in `PathBuf::FromSegments`. 2017-01-13 13:25:33 -08:00