GitHub and CI/CD Security at Postman

GitHub and CI/CD Security at Postman

Anish Sujanani

Introduction

Getting deep visibility into CI/CD security is hard. Settings are layered across enterprise, orgs, repos, branches and rulesets. CI/CD steps call cross-org workflows and third-party actions. Installed apps carry their own permissions, granted once and rarely revisited. Pipeline code tends to be written once and then left alone, and is not typically held to the same security standards of product code.

At Postman, we’ve been trying to answer these questions that span 23 orgs and over 6000 repositories. Some are years old, some created last week by an agent. Most have not gone through the rigorous security review process that product code goes through.

This post covers what we built:

  • A system that uses a dedicated app per org to pull org-level and repo-level settings, ruleset hierarchy, pages, webhooks, runners and installed apps among other settings.
  • CI/CD down-to-line resolution across composite workflows for code search and vulnerability analysis.
  • Raw data is evaluated for findings against 70 controls and multiple compliance suites.
  • An agentic approach to remediation at scale.
  • A single pane-of-glass to visualize findings, progress and trends.

How we built it

An overview of the system and its major components

The Initial Access

It all starts with a GitHub app, installed per organization. A minimal set of read-only permissions for the set of APIs we’re looking at and a private key in AWS.

Repository: Actions
Repository: Administration
Repository: Content
Repository: Metadata
Repository: Pages
Repository: Webhooks 
Org: Administration
Org: Custom Org roles
Org: Custom Repo roles
Org: Members
Org: Self-hosted Runners 
Org: Webhooks

Data fetch and Processing

Collection runs in a set of containers, one run per org. Each collector loads its Github app’s private-key from AWS Secrets Manager and signs a short-lived JWT. It exchanges that JWT for a one-hour installation token and repeats upon expiration.

From there, each collector runs a multi-threaded Python process: a configurable number of repo-level workers on pooled HTTP sessions, a rate-limit with backoff and retry shared across threads, bounded pagination, and per-repo checkpoints that let an interrupted run pick up where it stopped.

Below is a subset of APIs we call and some areas of interest.

API Use cases
Org Settings (/orgs/{org}) Member privileges, repo creation, visibility changes, forking rules, page deployment, teams and invites, default permissions, SSO and MFA
Members and roles (/orgs/{org}/members) Privileged users, email, keys and commit signing
Invitations (/orgs/{org}/invitations) Invite age, sender, receiver, SSO-integration
Org and Repo webhooks (/orgs/{org}/webhooks, /repos/{owner}/{repo}/hooks) Usage, TLS verification, HTTPS URLs
Apps (/orgs/{org}/installations, /orgs/{org}/installation-requests) Install date, permission grants, pending requests, usage and details
Org and Repo runners (/orgs/{org}/actions/runners, repos/{owner}/{repo}/actions/runners) OS, labels, usage
Repositories and content (/orgs/{org}/repos, /repos/{owner}/{repo}/contents) Foundational repo settings and file content – .gitignores, package lock files, workflows etc.
Branch protection and rulesets (/repos/{owner}/{repo}/branches/{branch}/protection, /repos/{owner}/{repo}/rulesets) )

Rule source (enterprise/org/repo), enforcement and target details

We also process effective rules – what actually applies after the hierarchy of rulesets resolves. Controls involve required approvals on PRs, status checks, force-push protection, review-dismissal, bypass rules.

Repo admins and collaborators (/repos/{owner}/{repo}/collaborators) Privileged users at the repo-level, repo members
Pages (/repos/{owner}/{repo}/pages) Page status, build time, visibility, DNS mapping
Workflows (/repos/{owner}/{repo}/actions/workflows, <code>/repos/{owner}/{repo}/contents/{path}) Workflow file analysis for actions, custom code and vuln. scanning
Run history (/repos/{owner}/{repo}/actions/runs) Name, conclusion, duration, actors, visualisation for compute time trends and failures
Branches, commits and tags (/repos/{owner}/{repo}/branches, /repos/{owner}/{repo}/commits, /repos/{action_owner}/{action_repo}/tags) Foundational, inventory, tagging and deployment verification

A note on workflows

Workflow files are not usually stand-alone. A job can be a list of steps or a single <code>uses</code> which points at another workflow, which has its own job recursively. We use the content API to pull workflow files and walk the job tree followed by flattening to an addressable path such as:

CI.build.steps[3].uses                 = actions/checkout@v4
CI.build.steps[4].run                  = npm ci && npm run build
Release.publish.resolved-from          = ./.github/workflows/publish.yml
Release.publish.jobs.npm.steps[2].run  = echo "${{ github.event.release.name }}" 

Code is indexed and searchable. We can query for injection vulnerabilities, timeouts, excessive permissions, credential storage, unusual operations in custom run-code, third-party action usage, version pinning, bot checks and package manager parameters among others. For example:

select * from pmsec_github_custom_code where run_command ~ '--force'
Sample query showing custom code and indexing

 

select * frompmsec_github_actions where action !~ '^(actions|postman.*)/'
Sample query results showing actions not prefixed with ‘actions’ or ‘postman’ with indexing

Execution

The collector runs in three ways:

  • Locally on security engineer machines, containerized
  • Started locally, executed on ECS
  • Scheduled by EventBridge, executed on ECS

Parameters for the run can be tuned via environment variables and control:

  • ECS network configuration – subnets, security groups
  • DB cluster ARNs
  • Toggle push to DB (or keep data local)
  • Toggle fetchers off (push local data to db)
  • Resuming interrupted runs
  • Multithreading options
  • DB upload batching and sizing, warmup procedures, retries and rollbacks
  • Pagination controls for individual GitHub APIs
  • Repo sampling: all | stale since n days | sampled to n%
  • GitHub rate limit backoff-and-retry parameters

Control Evaluation and Storage

Control evaluation takes place along with updates to mappings into compliance standards including FedRAMP, NIST, SAMM, etc (inspired by the SCF project). Raw data, control evaluation results and metrics are pushed to a serverless database. A container for visualization/dashboards, querying and alerting runs on the ECS cluster, accessible behind VPN and an Okta binding has been built for security engineers and management. A read-only JSON-ified interface into the DB is available for agents, leading into the remediation subsystem, but more on that later. The database schema and deep-dive into fields have been left out for brevity.


Visibility and Hunting

With the structured data model, post-processing and a read-only interface into the DB, we can get Claude to triage for us and build out our search. Some examples are given below.

Which users have admin rights on public repos but are not org admins?
Claude code skill showing redacted output
Sample results for the same query
List private repos with public Pages in org-x and org-y that were updated in the last 30 days.
Sample query results
List repos that have a workflow that pipes a remote script into a shell.
Sample query results
Where do our webhooks send data?
Sample query results
Give me a breakdown of cross-repo workflows with statistics on usage and refs/tags
Sample query results
Which jobs inject secrets into shell scripts and also use unpinned actions?
Sample query results
  • Which org moved most on a control?
  • What is the trend over time for missing gitignore files in org x for public repos?
  • Which run blocks of code appear exactly in more than 10 repos? (probably copied-and-pasted)
  • How many versions of some/action do we run?
  • Which repos had the most CI/CD activity last week but don’t enforce a ruleset against force merges?

… and more.


Remediation

However, querying for the problem is one thing. Fixing it across hundreds or thousands of repos is where the skills come in.

We use a set of Claude skills that sequence playbook documents and python tools per control, deterministic/in-code in most places and agentic reasoning in some. Security engineers currently use these on their local machines and we’re thinking about setting this on autopilot.

An overview of remediating missing timeouts on workflow steps

Breaking it down

/pmsec-status

Claude uses the db-read-interface tooling to generate a worklist from the control evaluation results and tracks on-system, PR-review and merged states. Jobs and state are written to the local ‘claims’ filesystem.

/pmsec-fix-many –org <> –control <> –batch <>

Picks a set from the job table, creates a claim to avoid overlap from other agents and routes to the workflow for that control. Each control’s workflow contains its own set of data and python tools. A couple of examples are summarised below

Example 01: Fix-steps for missing timeouts

  • Validate that each repo in the received job list meets the criteria for remediation.
  • SSH-clone the repo, plug p75, p90 and max-time data from the past n successful workflow runs into a formula that accounts for headroom within reason. If pipeline code contains developer defined timeouts within the run code itself, the job is marked for an agentic review.
  • Apply changes to a local branch. Picks a person based on past commits, time since last commit and fallbacks for a PR review (also in code, using the GitHub API and gh CLI). Waits for human review.
  • Once human-approved, push the branch, open the PR and assign the reviewer.

Example 02: Fix-steps for persisting credentials

  • Validate each repo in the received job list meets criteria for remediation.
  • SSH-clone the repo. Apply a list of classification rules on subsequent actions and label safe/unsafe/review based on whether they need the git token.
  • Items marked for review (usually third party actions that are not in the org) get an agentic review.
  • Agent reviews items, proposes fixes, and picks potential reviewers based on past commits, time since last commit and fallbacks (also in code, using the GitHub API and gh CLI). Agent also flags safe-to-push vs. human-review-needed workflows.
  • Once human-approved, push the branch, open the PR and assign the reviewer.

/pmsec-session-remediation-review

At any point, review the claims your current agent has open. Review pending fixes and address issues from the tooling/agentic review.

/pmsec-check-open

Go through open PRs, check for failing CI/CD jobs and debug to see if it was our change. Triage comments and suggest fixes.

… and other miscellaneous procedures for testing, quality and PR editing.


Conclusion

The features discussed through this post have contributed to:

  • Incident response tooling during supply chain attacks and CVE remediation, for example: search for supply-chain compromised actions, search for risky code directly embedded in workflows, malicious packages, etc.
  • Gap tracking and deterministic remediation at scale.
  • GRC and customer questions.
  • 3000 PRs raised and counting, accounting for between 80% and 100% reduction across multiple findings and multiple orgs.
  • Broader discussions with teams about process and standard procedures across the org.
  • Over 50 controls automated against multiple compliance frameworks.
  • Improved management for actions, third-party components and package management.
  • Improved and unified compliance across member privileges, repo creation and visibility, page creation and visibility, forking rules, role creation and management, invites and rulesets among others.
  • Improved visibility and correlation across other tools/services in the dev/deploy toolchain.

What do you think about this topic? Tell us in a comment below.

Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.