Open Source Security at Astral
Astral, the creators of popular tools like Ruff and uv, open-sources their extensive security playbook, detailing best practices to protect their projects from supply chain attacks. This technical deep-dive covers everything from hardened CI/CD workflows and stringent repository controls to secure release processes and dependency management. It's a goldmine for maintainers and developers seeking to bolster their own open-source security posture, resonating with HN's focus on practical, cutting-edge engineering solutions.
The Lowdown
In an era of increasing software supply chain attacks, Astral shares a detailed account of the security measures they implement across their open-source projects. This transparency aims to build user trust, provide actionable guidance for other maintainers, and inform CI/CD system developers about real-world security challenges. Their comprehensive strategy tackles various facets of modern software development, acknowledging that security is an ever-evolving challenge requiring continuous adaptation.
- CI/CD Security: Astral restricts dangerous GitHub Actions triggers like
pull_request_target, mandates pinning all actions to specific commit SHAs (verified by tools like zizmor), rigorously limits workflow and job permissions, and isolates GitHub Actions secrets using deployment environments. - Repository & Organizational Security: They enforce strict access controls by limiting privileged accounts, requiring strong 2FA (TOTP or stronger), and implementing organization-wide branch and tag protection rules. These rules prevent force pushes to
main, gate tag creation on successful releases, and ban repository admins from bypassing org-level protections. - Automations: For tasks GitHub Actions cannot perform securely (e.g., commenting on third-party PRs with elevated privileges), Astral utilizes a dedicated GitHub App (
astral-sh-bot) to isolate sensitive operations, emphasizing that app development still requires a strong security mindset. - Release Security: Astral employs Trusted Publishing to eliminate long-lived credentials, generates Sigstore-based attestations for verifiable artifact origins, and uses GitHub's immutable releases to prevent post-hoc modification of builds. They avoid caching during releases and use dedicated deployment environments with mandatory multi-person approvals to prevent malicious publications.
- Dependency Security: The company leverages Dependabot and Renovate with dependency cooldowns to manage and secure third-party dependencies. They also foster social connections with upstream projects, contribute financially via their OSS Fund, and are conservative about adding new dependencies or including binary blobs.
Astral concludes by emphasizing that open-source security is a dynamic, multifaceted problem. Key takeaways include respecting the limits of CI/CD, eliminating or isolating long-lived credentials, strengthening release processes, and maintaining continuous awareness of one's dependency landscape, recognizing that defenses must constantly evolve against determined attackers.