Shell commands built from strings

Lesson 9 of 27 · Injection and untrusted input · 2 min Get the course to watch

Customers want invoices as plain text, so the assistant reaches for a command line tool that converts a file. It builds the command as a string, hands it to a shell, and it works. Then a customer names a file with a semicolon in it.

Nothing about the failure is exotic. The code did exactly what it was told, and what it was told was to run a line of text that a stranger partly wrote.

The rest of this lesson

  • Why a shell is the problem
  • Watch the difference
  • Pass a list skip the shell
  • The quieter trap options
  • Ask whether you need a command at all
  • What to keep

The full lesson is animated and narrated, with a short quiz, and you can pause it to ask a question. It comes with Secure the code AI writes.