You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds verification of the file name (#18848) (#18909)
Verify the destination path to check some rules that avoid deliberate path traversal during extraction.
- avoid absolute path
- avoid symbolic links (only for tar.gz file)
- avoid paths with parent navigation, for example: `logstash/../../../something/in/target/host`
Covered all these branches with unit tests.
(cherry picked from commit c4d7362)
Co-authored-by: Andrea Selva <selva.andre@gmail.com>
expect{subject.extract(source,target)}.toraise_error(LogStash::CompressError,/Refusing to extract file to unsafe path.*Files may not traverse with `..`/)
124
+
end
125
+
82
126
context"patterns"do
83
127
# Theses tests sound duplicated but they are actually better than the other one
expect{subject.extract(source,target)}.toraise_error(LogStash::CompressError,/Refusing to extract file to unsafe path.*Files may not traverse with `..`/)
237
+
end
238
+
239
+
it"raises CompressError when tarball contains a symlink entry"do
This archive is the same as `sample.tgz` plus a symbolic link `GeoLite2-City-alias.mmdb` → `GeoLite2-City.mmdb` at the archive root. `LogStash::Util::Tar.extract` rejects symlink entries, so this fixture is only for specs that assert that behavior. Run from this directory (Unix/macOS):
0 commit comments