News for hackers. Stuff that matters.
Re:More Things I Wish I’d Known About Bash by ckuehl on Sunday January 21, 2018 @02:55PM (#16199633)
This is a somewhat dangerous pattern for picking temporary files (from #8):

    $ NEWFILE=/tmp/newfile_${RANDOM}
    $ touch $NEWFILE

The problem is that any user on the box can create files under /tmp. An attacker can set up a bunch of symlinks like /tmp/newfile_1, ..., /tmp/newfile_99999 pointing to a file owned by your user. When your script then writes into this temporary file, you'll write through the symlink and clobber one of your own files. Especially dangerous if root :)

This has been a historic source of software vulnerabilities (often with the PID used instead as the guessable component instead of random, though). One recommended alternative is to use the `mktemp` command instead.

Re:More Things I Wish I’d Known About Bash by jwilk on Sunday January 21, 2018 @06:05PM (#16200621)
Nitpick: $RANDOM gives you an integer between 0 and 32767 (inclusive).
Re:More Things I Wish I’d Known About Bash by xchaotic on Sunday January 21, 2018 @04:32PM (#16200157)
this is from a guy writing abook on Docker, so I hope this is for a single purpose cointainer with now other users of THAT /tmp
Re:More Things I Wish I’d Known About Bash by cryptonector on Monday January 22, 2018 @11:49AM (#16205793)
it's a very dangerous pattern. Use mktemp(1) instead!