RustEmbed generated `get` method allows for directory traversal when reading files from disk
Moderate severity
GitHub Reviewed
Published
Jun 17, 2022
to the GitHub Advisory Database
•
Updated Jan 12, 2023
Description
Published to the GitHub Advisory Database
Jun 17, 2022
Reviewed
Jun 17, 2022
Last updated
Jan 12, 2023
When running in debug mode and the
debug-embed
(off by default) feature isnot enabled, the generated
get
method does not check that the input path isa child of the folder given.
This allows attackers to read arbitrary files in the file system if they have
control over the filename given. The following code will print the contents of
your
/etc/passwd
if adjusted with a correct number of../
s depending onwhere it is run from.
The flaw was corrected by canonicalizing the input filename and ensuring that
it starts with the canonicalized folder path.
References