1

I recently discovered that concatenating text to the end of a PDF file does not change properties of the PDF file. This may be a very silly question, but if a program were concatenated to the PDF file, could it somehow be executed?

For example, opening this PDF file would create a text file in the home directory with the words "hello world" in it.

*pdf contents*...
trailer^M
<</Size 219/Root 186 0 R/Info 177 0     R/ID[<5990BFFB4DF3DB26CE6A92829BB5C41B>    <B35E036CA0E7BA4CBF39B3D74DCE4CAF>]/Prev 4494028 >>^M
startxref^M
4663747^M
%%EOF^M
#!/bin/bash
echo "hello world" > ~/hello.txt

Would this work with a different file format? Does the embedded code need to be a binary executable?

2
  • You could use this to make a PDF file also valid in a footer-based format, like ZIP, but not a header-based format, like... well, basically all your executable formats, scripting or otherwise. A shebang, like other headers, will only be recognized at the top of a file. Commented May 22, 2016 at 18:10
  • 1
    In general, though, a "is this design decision exploitable?" question is probably a better fit for security.stackexchange.com than SO. Commented May 22, 2016 at 18:12

1 Answer 1

2

As (fortunately), that's not part of the standard, you can't do that.

Unfortunately, the standard supports "launch actions", to execute arbitrary code with user confirmation. Those are now disabled by default and don't allow to execute embedded bulbs, but if enabled you could use that to execute arbitrary code that finds and executes the code embedded on the pdf.

The standard also supports javascript that excecutes sandboxed, but it a reader specific bug that allows may escaping the sandbox.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.