CodeCargo logo

Security

Add CargoWall to Workflows

CargoWall runs as a step in each job, code-cargo/cargowall-action. CodeCargo can open the pull requests that add it, or you can add it yourself. Either way, once the step gets its policy from CodeCargo, jobs run in audit until you move them to enforce. A step that gets no policy runs on its own inputs, which enforce by default. See How the Step Gets Its Policy.

Add CargoWall Automatically

  1. Open CargoWall in your organization, or in a project for just its repositories.
  2. On Overview, click Add to workflows. The Add CargoWall to workflows dialog lists the workflows that don't run CargoWall yet, grouped by repository, all selected.
  3. Under Target version, pick a release. The list is the action's newest releases, newest first, with the first already selected. Pre-releases (-rc tags) are listed too, unmarked. A shield marks an Immutable tag. To type a tag, branch or commit SHA instead, choose Enter version manually.
  4. Leave Pin to a commit SHA ticked, as it starts, or clear it to reference the version itself. See Pinning the Version.
  5. Clear any repositories or workflows you don't want to change.
  6. Click Open N pull requests. CodeCargo opens one pull request per repository.

Once a pull request merges, CargoWall watches that workflow's outbound connections from its next run.

The Add CargoWall to workflows dialog: Target version lists the releases v1.4.0, v1.3.2, v1.3.1 and v1.3.0, with v1.4.0 selected and the first two marked as immutable, then Enter version manually, and Pin to a commit SHA ticked, saying workflows reference the commit v1.4.0 points to now with v1.4.0 kept as a comment. Below, four workflows in catalog-api, identity-gateway and orders-worker are all selected, beside Cancel and Open 3 pull requests

Only an organization admin can add CargoWall this way. Everyone else sees Add to workflows turned off, with Ask an organization admin to add CargoWall to your workflows. on hover or focus.

Before any workflow has reported, the Overview shows Get started with CargoWall in place of the dashboard: add CargoWall to your workflows, create a policy, assign it to your repositories, and run your workflows. An organization admin gets Add automatically there, which opens the same dialog, and View full setup instructions links to the action's README.

Which Workflows Are Listed

The dialog lists workflows on the default branch of your active repositories that don't already reference code-cargo/cargowall-action and have at least one job that runs its own steps. It leaves out reusable workflows (those that declare on: workflow_call) and GitHub Agentic Workflows files. Copies the Migration Assistant archived, or is transferring out of the organization, aren't listed or counted, since no pull request can open there.

From the organization, an organization admin is offered every active repository's workflows. In a project, the dialog lists only the project's repositories you can read on GitHub, even for an organization admin. Over the API or MCP, anyone else is offered only workflows in repositories they can read on GitHub.

Pinning the Version

With Pin to a commit SHA ticked, each workflow references the commit the version points to now, with the version kept as a comment. A moving tag such as v1 is commented with the release at that commit (# v1.3.12) when there is one.

CodeCargo resolves the version when you click Open N pull requests, so a version it can't pin is refused while you wait, naming the version. It doesn't fail later in every repository's pull request.

A version you type that already names one commit has nothing to pin, so the pin choice goes away: a full 40-character SHA, a pull request's ref such as pull/12/head, or another ref outside branches and tags. An abbreviated SHA keeps the choice, and pinning resolves it to the full SHA. CodeCargo accepts a commit only if it is in code-cargo/cargowall-action's own history: reachable from its default branch, or the commit of one of its tags. A commit that exists only in a fork is refused.

The release you install, or move the action to with Update action, becomes your organization's CargoWall release. When a Migration Assistant conversion adds the CargoWall step, it pins that release, or the latest release until your organization has one.

What the Pull Request Changes

Each pull request adds a step named CargoWall as the first step of every job that runs its own steps. The step has no inputs: its mode and rules come from CodeCargo. The job also gets the permissions CargoWall needs, contents: read, actions: read and id-token: write. Outside a reusable workflow that also runs on its own triggers, it never loses a permission it had:

  • A job with its own permissions: block gets those three added or raised there.
  • A job without one starts from the workflow's permissions:, with the three added or raised. A workflow-level read-all is spelled out with every scope it grants, plus id-token: write. When the workflow's permissions already grant all three, or it sets write-all, the job gets no block of its own.
  • When neither the job nor the workflow sets permissions, the job gets a block that spells out the repository's default token permissions, with actions: read and id-token: write added.

Jobs that call a reusable workflow, have no steps, or already run CargoWall are skipped. Jobs whose steps are an inline list (steps: [...]), and jobs whose repository default token permissions CodeCargo couldn't confirm, are left without CargoWall and listed under Left alone in the pull request, with what to add by hand.

When CodeCargo adds the step to a reusable workflow, as a Migration Assistant conversion can, a workflow that runs only when another calls it (on: workflow_call alone) runs on its caller's token. A job in it that sets no permissions, under a workflow that sets none, gets the CargoWall step and no permissions: block, so it keeps every scope its caller passes down. The jobs that call it need actions: read and id-token: write. A Migration Assistant conversion raises those for callers it changed in the same repository. Other callers need them added by hand.

In a reusable workflow that also runs on its own triggers, a job that sets no permissions, under a workflow that sets none, gets a block of just contents: read, actions: read and id-token: write. That is less than the repository's default token gives it on its own triggers, so add the scopes it uses before you merge.

Migration Assistant Conversions

A Migration Assistant conversion adds the CargoWall step to each converted workflow in the same way, pinned to your organization's CargoWall release. It never sets a CargoWall mode: each repository keeps its own, or takes its organization's. See CargoWall in Converted Workflows.


Add CargoWall by Hand

Add the step as the first step of each job, and give the job the permissions CargoWall needs:

YAML
jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      actions: read # names steps in the job summary
      id-token: write # proves to CodeCargo which repository and run this is
    steps:
      - name: CargoWall
        uses: code-cargo/cargowall-action@6394eff6547b786645e8ebea1ab9123efa7b589e # v1.3.12
      - uses: actions/checkout@v4
      # the job's other steps

That's all a repository connected to CodeCargo needs: the job's mode and rules come from the policy you manage in CodeCargo. Without id-token: write the step can't fetch the policy or report the run, and falls back to its own inputs, which enforce by default.

Pin the Action

The v1 tag moves with each release. To pin the step, use a release's commit SHA, with the release kept as a comment, as above. Each action release also pins the CargoWall binary it downloads, by version and checksum, so pinning the action pins the firewall too. The pull requests CodeCargo opens pin it this way by default.

Inputs

The step's inputs matter most when it doesn't get a policy from CodeCargo: in a repository that isn't connected, with offline: true, or when CodeCargo can't be reached. A policy from CodeCargo replaces mode, allowed-hosts, allowed-cidrs, config-file and search-domains. The other inputs still apply, and sudo-lockdown stays on unless a policy turns sudo lockdown on itself.

InputDefaultWhat it does
modeenforceenforce or audit
api-failure-modeauditWhat to do when the policy can't be fetched. See How the Step Gets Its Policy
allowed-hostsHostnames to allow, one per line. A plain hostname also matches its subdomains. One with a * or ** wildcard matches only its pattern, and allows every port unless you add ports (example.com:443)
allowed-cidrsIP ranges to allow, one per line
search-domainsDNS search domains, one per line. See Search Domains
config-fileA YAML or JSON file of rules, for more than the inputs can express
sudo-lockdownfalseRestrict sudo for the job. See Sudo Lockdown
sudo-allow-commandsFull paths of commands sudo may still run, one per line
fail-on-unsupportedfalseFail the step on a Linux runner without eBPF, or when CargoWall fails to start. Otherwise it warns and the job continues unprotected
allow-existing-connectionstrueLet through TCP connections opened before CargoWall started
audit-summarytrueWrite CargoWall's summary to the job summary
offlinefalseDon't contact CodeCargo: no policy fetch and no run report
api-urlhttps://app.codecargo.comThe CodeCargo API
debugfalseDebug logging

The action's README lists the rest, such as dns-upstream, binary-path, and the GitHub and Azure hosts CargoWall auto-allows. The step's outputs are supported, true when the firewall started, and pid, the firewall's process.

How the Step Gets Its Policy

When the job starts, the step asks CodeCargo for the job's effective policy, proving which repository and run it is with the job's GitHub OIDC token:

  • The repository is connected to CodeCargo. The job runs the policy CodeCargo sends, in the mode CodeCargo sets, whatever the step's inputs say. A connected repository with no policy assigned gets a policy that allows nothing beyond the auto-allowed hosts. In audit, the default, that blocks nothing.
  • The repository isn't connected, the organization's plan isn't active, or the job has no OIDC token. The step runs on its own inputs. Its own default mode is enforce, so the step CodeCargo adds, which has no inputs, blocks everything but the auto-allowed hosts. That includes pull requests from forks, which GitHub gives no OIDC token. Set mode: audit in the step if those runs must not block.
  • CodeCargo can't be reached, or answers with a server error. The step retries for up to 10 seconds, then follows api-failure-mode: audit runs the step's inputs in audit, enforce runs them as given, and fail blocks everything but the auto-allowed hosts and fails the step.

An Unreachable API Turns Off Blocking

With the default api-failure-mode: audit, a runner that can't reach app.codecargo.com runs every job in audit. If a runner's network must never fall back to audit, set api-failure-mode: enforce with rules in the step, or fail. Setting mode in the step also changes the api-failure-mode default to enforce.

Reporting a run from a repository that isn't active in CodeCargo activates it, while your plan has room for more active repositories.

Runner Requirements

  • Linux, x64 or arm64. On macOS and Windows runners the step fails with CargoWall only supports Linux. Ready to Enforce holds back a scope whose jobs run there.
  • Passwordless sudo, as GitHub-hosted runners have.
  • Kernel 5.8 or later with eBPF. On a Linux runner without eBPF, or when CargoWall fails to start, the step warns and the job continues unprotected, unless fail-on-unsupported is set.
  • A fresh runner per job. The step doesn't stop the firewall, restore DNS or undo sudo lockdown when the job ends. GitHub-hosted runners are discarded after each job. Run self-hosted runners as ephemeral runners too.

At the end of the job, CargoWall writes a summary of the job's connections to the job summary on GitHub. Once the run has reported to CodeCargo, the summary is a link instead: View full details on CodeCargo. It opens the run in CargoWall, or the public run page for a public repository.