Skip to main content
A compromised package can send your CI secrets to a host that the attacker controls. A network policy lists the hosts that a job can reach. The PMG proxy refuses every other destination, and the job fails.
Network policy needs safedep/[email protected] or later. Use it with enforce: true. Without kernel enforcement, a process can ignore the proxy variables and connect directly. See PMG in GitHub Actions.

Build the policy from a run

The proxy records every destination that a job reaches. Run the job once with no policy, then turn the run into a profile.
1

Add the proposal steps to the job

The action exports the run ID as PMG_PROXY_RUN. The run ID comes from the event log, so do not set skip-event-logging: true.
2

Run the workflow and download the artifact

The pmg-network.yml file has one allow rule for each host that the job reached, and a rule that denies every other destination.
3

Review and commit the profile

Remove each host that the job does not need. Commit the file as .pmg/profiles/ci.yml.
4

Protect the profile

The profile controls what the job can reach, so give it the same review as the workflow file. Add a CODEOWNERS line:

Enforce the policy

Set network-profile and network-mode on the action. Remove the proposal steps.
The proxy refuses each destination that the profile does not allow. The stop step fails the job, and its report names the destination, the rule, and the program. To add new destinations to the profile, run the job with network-mode: audit and the proposal steps. In the proposal step, use --into .pmg/profiles/ci.yml in place of --new pmg-network.yml, and upload .pmg/profiles/ci.yml. In enforce mode, the proxy refuses a new destination, so the proposal gets no rule for it.

Next steps

For the steps without enforce and the steps with config-file, see Build the profile from a run in the PMG action documentation. For the input table, see Inputs.

PMG in GitHub Actions

Set up the PMG action and kernel enforcement.

Limit the Hosts a Package Install Can Reach

Apply a network policy on a developer machine.