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.
This commit also includes the following changes:
* `FromRequest` for `SocketAddr` implemented: extracts remote address.
* All built-in `FromRequest` implementations are documented.
* Request preprocessing overrides remote IP with value from X-Real-IP header.
* `MockRequest` allows setting the remote address with `remote()`.
Resolves#38.
This commit improves and changes the templating library in the following ways:
* Templates are now registered/loaded at initialization.
* No synchronization is required to read templates.
* All templates are properly loaded (fixes#122).
* Tera templates are given the proper name: `index`, not `index.html.tera`.
* Rendering tests added for both templating engines.
There is one breaking change:
* Tera templates are given the proper name: `index`, not `index.html.tera`.
* Add Config::new() and Config::build() for simpler Config creation.
* Add set_{param} methods to Config.
* Add ConfigBuilder type for easy building of configurations.
* Remove builder methods from Config.
* PartialEq in Config doesn't consider path or session key.
* Rocket::custom takes Config by value.
* Rocket::custom takes second (enable_logging) boolean argument.
* Rocket::custom properly sets the custom config as the active config.