-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom tmpdir arg (first try) #8
Conversation
Attempt to add a --tmpdir arg. The --shared option can be very useful but also a little dangerous if you don’t trust what’s in the /tmp directory. Giving Arx a custom location for the temp directory should make things a little bit safer. Most useful in this case, $ arx tmpx --shared --tmpdir '$HOME/.cache' my.tar.bz2 This will put things in your HOME directory where you can be fairly sure no one else has snuck in a temporary directory to fool you into using something that is malicious. Using /tmp as a shared directory can be exploited if you know the hash ahead of time. Just something as simple as this, $ tmp=$(mktemp -d tmpx-HASH) $ echo "rm -rf /" > $tmp/run where HASH is the hash of the dat, can create a privilege escalation when Arx runs the /run script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. The changes I'm requesting relate to (a) formatting and (b) shell quoting.
model-scripts/tmpx.sh
Outdated
else | ||
dir=/tmp/tmpx-"$token" | ||
dir=$tmpdir/tmpx-"$token" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$tmpdir
-> "$tmpdir"
for shell quoting safety.
model-scripts/tmpx.sh
Outdated
@@ -39,9 +39,9 @@ opts() { | |||
if $shared | |||
then | |||
rm_=false | |||
dir=/tmp/tmpx-"$hash" | |||
dir=$tmpdir/tmpx-"$hash" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$tmpdir
-> "$tmpdir"
for shell quoting safety.
System/Posix/ARX/TMPXTools.hs
Outdated
@@ -22,12 +22,13 @@ import Data.Hashable | |||
data Template = Template { rm0 :: Bool, {-^ Remove tmp on run success? -} | |||
rm1 :: Bool, {-^ Remove tmp on run error? -} | |||
shared :: Bool, {-^ Share directory across runs? -} | |||
tmpdir :: String, {-^ Location to store tmp files.-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Location for tmp files.
would allow a little more space.
System/Posix/ARX/CLI/Options.hs
Outdated
@@ -98,6 +101,8 @@ qPath = tokCL QualifiedPath | |||
shared :: ArgsParser Bool | |||
shared = True <$ arg "--shared" | |||
|
|||
tmpdir :: ArgsParser Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
␣::␣ArgsParser Path
-> ::␣␣ArgsParser Path
for consistency with surrounding code.
System/Posix/ARX/CLI/Options.hs
Outdated
@@ -98,6 +101,8 @@ qPath = tokCL QualifiedPath | |||
shared :: ArgsParser Bool | |||
shared = True <$ arg "--shared" | |||
|
|||
tmpdir :: ArgsParser Path | |||
= arg "--tmpdir" >> QualifiedPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=␣arg "--tmpdir" >> QualifiedPath
-> =␣␣arg "--tmpdir" >> QualifiedPath
for consistency with surrounding code.
Fixes review issues & more.
I will rebuild and re-release this week. Thanks for your patch. |
Attempt to add a --tmpdir arg.
The --shared option can be very useful but also a little dangerous if
you don’t trust what’s in the /tmp directory. Giving Arx a custom
location for the temp directory should make things a little bit safer.
Most useful in this case,
$ arx tmpx --shared --tmpdir '$HOME/.cache' my.tar.bz2
This will put things in your HOME directory where you can be fairly
sure no one else has snuck in a temporary directory to fool you into
using something that is malicious.
Using /tmp as a shared directory can be exploited if you know the hash
ahead of time. Just something as simple as this,
$ tmp=$(mktemp -d tmpx-HASH)
$ echo "rm -rf /" > $tmp/run
where HASH is the hash of the dat,
can create a privilege escalation when Arx runs the /run script.
This is already (hackily) done by patching tmpx.sh in nix-bundle, but I would prefer to get it working as an are.
https://github.com/matthewbauer/nix-bundle/blob/master/default.nix#L8-L9