New Tool Radar

AI PDF

How to Check a PDF for JavaScript Actions Before Opening or Sharing It

List the document JavaScript strings and document actions in Acrobat to see what code a PDF will run before you trust it.

Schematic with three steps: List all JavaScript strings in the document; Check document actions and field actions; Decide whether the scripts are safe to.

A PDF can carry JavaScript tied to the document, a page, a field, or an action such as opening the file. Some scripts are harmless form logic; others exfiltrate data or change the document. Listing the scripts before opening or sharing the file tells you what code you are dealing with.

What you need

  • Adobe Acrobat
  • A PDF received from an outside source
  • A copy of the file kept aside until it is checked

Step 1: List all JavaScript strings in the document

Open the PDF in Acrobat, choose All tools, then Use JavaScript, then All javascript strings, and read the list of document-level scripts.

Step 2: Check document actions and field actions

Open the Document actions dialog and the Actions tab of each form field to see which triggers, such as Mouse Up or On Blur, run a script.

Step 3: Decide whether the scripts are safe to keep

Read each script and judge whether it only formats fields or does something the document does not need. Remove unnecessary scripts, or refuse the file if a script looks malicious, before sharing it further.

Worked example: synthetic JavaScript check on a received form

The table below is a synthetic example. It shows the expected result of the script listing; no listing was run.

Location Script Verdict
Document open None Clean
Submit button Format date field Harmless, keep
Page 2 field Send data to external URL Remove before sharing
Total 2 scripts 1 script to remove

Expected result (UNTESTED). the submit button script only formats a date, but a field on page 2 sends data to an external address, so that script must be removed before the file is shared. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Listing scripts shows their text; understanding what a script does needs care, especially with obfuscated code.
  • Acrobat’s JavaScript debugger can inspect code, but running a suspicious script to test it is unsafe.
  • Removing JavaScript can break form calculations that depend on it, so test the form after removal.

Sources

See all