Comment by staticassertion

Comment by staticassertion 3 days ago

8 replies

What if you wrote something more like:

    # terrible code, never use ty
    def cleanup(dir):
      system("rm -rf {dir}")


    def main():
        work_dir = os.env["WORK_DIR"]
        cleanup(work_dir)
and then due to a misconfiguration "$WORK_DIR" was truncated to be just "/"?

At what point is it negligent?

direwolf20 3 days ago

This is not hypothetical. Steam and Bumblebee did it.

  • extraduder_ire 3 days ago

    That was the result of an additional space in the path passed to rm, IIRC.

    Though rm /$TARGET where $TARGET is blank is a common enough footgun that --preserve-root exists and is default.

    • cyberax 3 days ago

      Even better, $TARGET might be "/home/user/documents and settings /bin"

      • extraduder_ire 2 days ago

        I believe that is what staticassertion was suggesting. / is a poor example because of --preserve-root being the default.

        • cyberax 2 days ago

          Not quite. The grandparent's example was missing quotes around $TARGET. Which is yet _another_ footgun.

          Without quotes it becomes: `rm -Rf /home/user/documents and settings /bin`