in
|
return True if path.startswith(basedir) else False |
, using
path.startswith(basedir) without a trailing directory separator allows directory traversal if a target directory shares a common prefix. For example, if
basedir is
/tmp/target, and
path is
../target_hack,
os.path.realpath resolves it to
/tmp/target_hack, which passes the
startswith check and allows writing outside the base directory.
in
ubi_reader/ubireader/ubifs/output.py
Line 40 in f2197d4
path.startswith(basedir)without a trailing directory separator allows directory traversal if a target directory shares a common prefix. For example, ifbasediris/tmp/target, andpathis../target_hack,os.path.realpathresolves it to/tmp/target_hack, which passes thestartswithcheck and allows writing outside the base directory.