SECURITY Policy Files
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 10 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Mastering Security Policy Files in GitHub Repositories
Introduction: Why Security Policies Matter
In the modern landscape of software development, security is no longer an afterthought or a task solely for a dedicated security team. As developers, we are responsible for the code we write, the dependencies we import, and the way our projects interact with the wider world. When you host your code on GitHub, you are participating in a massive ecosystem of open-source collaboration. This ecosystem relies on trust, and one of the most effective ways to establish that trust—and to handle potential vulnerabilities—is through the implementation of a SECURITY.md file.
A security policy file is a plain-text document located in your repository that provides clear instructions to researchers, users, and contributors on how to report security vulnerabilities. When a security researcher discovers a flaw in your code, they need a safe, private, and standardized channel to inform you. If you lack this file, they may post the vulnerability publicly in an issue or on a social media platform, effectively broadcasting the flaw to malicious actors before you have a chance to patch it. By providing a SECURITY.md file, you create a structured path for responsible disclosure, protecting both your users and your project’s reputation.
Furthermore, GitHub automatically detects these files and displays them when users attempt to open a new issue. This subtle nudge encourages researchers to follow your preferred reporting process rather than dumping sensitive information into a public forum. In this lesson, we will explore the anatomy of a security policy, how to create one, what information to include, and the industry best practices for maintaining a secure repository.
Not read yet
The Anatomy of a SECURITY.md File
A well-crafted security policy file does not need to be a dense, legalistic document. In fact, brevity and clarity are your best friends here. The goal is to make it as easy as possible for someone to contact you securely. If the instructions are too complicated, a researcher might give up or revert to less secure methods of reporting.
At a minimum, your policy should address the following core components:
- Supported Versions: Clearly state which versions of your software are currently receiving security updates. This manages expectations for contributors and users alike.
- Reporting Procedures: Provide a specific email address, a private channel, or instructions on how to use GitHub’s private vulnerability reporting feature.
- Response Expectations: Give a rough timeline of when a reporter can expect an acknowledgement or a fix. This builds trust.
- Disclosure Policy: Explain your stance on public disclosure. Do you reward researchers? Do you credit them in release notes?
Example Structure
Here is a simple, effective template you can adapt for your projects:
# Security Policy
## Supported Versions
We currently provide security updates for the following versions:
| Version | Supported |
| :--- | :--- |
| 2.x | Yes |
| 1.x | No |
## Reporting a Vulnerability
If you discover a security vulnerability, please do not report it in a public issue. Instead, send an email to [email protected]. We prioritize all reports and will respond within 48 hours.
## Disclosure
We appreciate the work of security researchers. We will credit you in our release notes if you wish to be acknowledged. We ask that you keep the vulnerability private until we have released a patch.
Not read yet
Best Practices for Implementation
When writing your security policy, keep your audience in mind. You are writing for security researchers who often have a high volume of reports to file across many different projects. They value efficiency and clear expectations.
1. Use Private Vulnerability Reporting
GitHub now offers a built-in feature called "Private Vulnerability Reporting." This allows users to report issues directly through the GitHub interface without creating a public issue. This is significantly more secure than email, as it keeps the conversation within the GitHub ecosystem while ensuring the data remains hidden from the public until you are ready to publish a security advisory.
Callout: Email vs. GitHub Private Reporting While email is the classic way to receive reports, it has limitations. Emails can be lost in spam folders, and they lack the structured workflow of a ticket. GitHub’s private reporting feature keeps the vulnerability report linked to your repository, allows for back-and-forth communication, and simplifies the process of generating a Security Advisory when you are ready to publish the fix. We strongly recommend enabling this feature in your repository settings.
2. Be Explicit About "Supported Versions"
One of the most common points of confusion in open-source projects is whether a bug in an old version is worth reporting. By maintaining a table of supported versions, you save yourself from triaging reports for software that you no longer maintain. If someone reports a vulnerability in an unsupported version, you can simply point them to your SECURITY.md file, which explains why you are not fixing it.
3. Establish a Response Timeline
You do not need to promise a fix within a specific hour, but providing a general expectation helps. For example, stating "We acknowledge all reports within 3 business days" is a professional commitment. If you are a solo maintainer, be honest about your capacity. A statement like, "As this is a volunteer-run project, please allow up to one week for an initial response," is perfectly acceptable and prevents frustration on both sides.
Not read yet
Step-by-Step: Adding a Security Policy to Your Repository
Adding a security policy is straightforward. GitHub even provides a template generator to get you started.
- Navigate to your repository on GitHub.
- Click the "Security" tab in the navigation bar near the top of the page.
- If you do not have a policy yet, you will see a prompt to "Set up a security policy."
- Click "Start setup" to open the editor.
- GitHub will provide a default template. Edit this template to include your specific contact information and versioning details.
- Commit the file to your repository. It is best practice to place this file in the root directory or within a
.github/folder.
Important Considerations for the File Location
While placing the file in the root directory is standard, many developers prefer the .github/ folder to keep the repository root clean. GitHub is intelligent enough to detect the file in either location. If you have multiple repositories in an organization, you can also create a community repository and place a SECURITY.md file in the .github/ folder there. GitHub will use that as a default policy for all repositories in your organization, saving you from having to copy-paste the file into every single project.
Not read yet
Common Pitfalls to Avoid
Even with the best intentions, developers often make mistakes when managing security policies. Here are the most common traps and how to avoid them.
Pitfall 1: Using a Personal Email Address
Avoid using your personal email address for security reports. If you leave the project or lose access to that account, the reporting channel dies. Instead, use a dedicated email alias (e.g., [email protected]) or a generic organizational address. This ensures that the responsibility of monitoring the inbox can be shared among multiple maintainers.
Pitfall 2: Over-promising on Compensation
Some projects feel the need to promise "bug bounties" or monetary rewards in their security policy. Unless you have a formal program and a budget to support this, do not mention it. It is perfectly fine to say, "We do not currently have a bug bounty program." It is better to be clear about this upfront than to deal with researchers who feel entitled to payment.
Pitfall 3: Not Updating the File
A stale SECURITY.md file is worse than no file at all. If you list an email address that is no longer monitored, or if you list versions as "supported" that you have actually deprecated, you create a false sense of security. Set a recurring task, perhaps every six months, to review your security policy and ensure the contact information and version lists are still accurate.
Note: The "Security" Tab vs. The File The
SECURITY.mdfile is a static document, but the "Security" tab in your GitHub repository is a dynamic dashboard. Ensure that your policy instructions align with the tools enabled on that tab. If you have enabled Private Vulnerability Reporting, make sure yourSECURITY.mdfile mentions that this is the preferred method.
Not read yet
The Role of Security Advisories
Once a vulnerability has been reported and confirmed, the next step is not just patching the code, but communicating the risk. This is where GitHub Security Advisories come into play. A security advisory is a structured way to inform your users about a vulnerability, explain the impact, and provide a fix.
When you create a security advisory, you can:
- Assign a CVE (Common Vulnerabilities and Exposures) ID: This is a standardized identifier that helps security tools track the vulnerability across the industry.
- Specify the affected versions: You can define exactly which versions are vulnerable.
- Provide a patch: You can link the specific commit or pull request that resolves the issue.
- Publish to the GitHub Advisory Database: This makes your security information publicly available to the global security community, allowing dependency checkers (like Dependabot) to warn other developers who use your code.
By integrating your SECURITY.md file with the Security Advisory process, you create a complete lifecycle for security management: Report (via policy) -> Triage (via private reporting) -> Fix (via advisory) -> Communicate (via public disclosure).
Not read yet
Comparing Reporting Channels
To help you decide how to structure your reporting, consider the following table:
| Channel | Pros | Cons |
|---|---|---|
| GitHub Private Reporting | Integrated into workflow, private by default, no third-party tools needed. | Only works if the reporter has a GitHub account. |
| Dedicated Email | Accessible to anyone, easy to set up. | Can be missed, lacks ticketing features, requires manual tracking. |
| External Security Platform | Professional, handles bounties and triage for you. | Often expensive, requires integration with their platform. |
For most individual developers and small teams, GitHub Private Reporting is the gold standard. It is free, built-in, and highly effective. For larger organizations, a combination of an email address for initial contact and an internal ticketing system is common.
Best Practices for Maintaining a Secure Repository
A security policy file is only one piece of the puzzle. To truly manage repository security, you must adopt a holistic approach.
1. Enable Automated Security Tools
GitHub provides several tools that you should enable on every repository:
- Dependabot Alerts: Automatically notifies you when your dependencies have known vulnerabilities.
- Dependabot Security Updates: Automatically creates pull requests to update vulnerable dependencies to a safe version.
- Secret Scanning: Scans your code for accidentally committed secrets, such as API keys or database credentials.
2. Principle of Least Privilege
Ensure that only the necessary people have write access to your repository. Use branch protection rules to prevent anyone—even maintainers—from pushing code directly to the main or production branches without passing status checks and code reviews. This prevents a compromised contributor account from injecting malicious code into your production environment.
3. Code Signing
Encourage your contributors to sign their commits using GPG or SSH keys. This verifies that the code actually came from the person they claim to be. While this is more common in large-scale projects like the Linux kernel, it is an excellent practice for any repository where supply chain security is a priority.
4. Regular Dependency Audits
Even if you use automated tools, perform a manual audit of your project’s dependencies periodically. Ask yourself: "Do we really need this library?" Every dependency you add is a potential security vector. Keeping your dependency tree lean and mean is one of the most effective ways to reduce your attack surface.
Warning: The "Trusting Dependencies" Trap Never assume a library is safe just because it is popular. Popularity does not equate to security. Always check the repository's activity, the number of open security issues, and the date of the last commit before adding a new dependency to your project.
Not read yet
Handling a Vulnerability Report: A Practical Workflow
When you receive a report via your SECURITY.md channel, it is crucial to handle it with care. Panic leads to mistakes, and mistakes in security are costly. Follow this structured process:
- Acknowledge Receipt: Respond to the reporter immediately. Let them know you have received the report and are investigating. You don't need to commit to a timeline yet, just show that the channel is active.
- Verify the Vulnerability: Reproduce the issue in a local, isolated environment. Never test exploits against live production data. If you cannot reproduce it, ask the researcher for more details or a proof-of-concept script.
- Draft the Fix: Create a new branch for the fix. Do not discuss the vulnerability in public pull requests or issues. Keep the conversation contained in the private report or a private branch.
- Coordinate Disclosure: If the vulnerability is critical, you may need to coordinate the release of the patch with other parties. If you are part of a larger ecosystem, communicate with them so they can update their systems simultaneously.
- Publish the Advisory: Once the patch is merged and deployed, publish a GitHub Security Advisory. This informs your users that they need to update their software.
- Thank the Researcher: This is the most important step for the long-term health of your project. Publicly (or privately) thank the researcher for their help. A positive experience encourages them to report future issues to you rather than selling them to malicious actors.
Not read yet
Detailed Example: Creating a SECURITY.md with GitHub's Tooling
Let’s walk through the exact steps to create a high-quality file.
Step 1: The Header
Start with a clear title. Use Markdown headers to make it scannable.
# Security Policy
Step 2: The Scope
Define what is in scope. You don't want people testing your website's login page if you only wanted them to test your library's API.
## In Scope
- The core library code located in the `/src` directory.
- Publicly available releases on npm/pip.
## Out of Scope
- The project's marketing website (example.com).
- Third-party dependencies (please report these to the respective maintainer).
Step 3: The Reporting Process
Be specific. If you have a private reporting link, put it here.
## Reporting a Vulnerability
We encourage you to use the [GitHub Private Vulnerability Reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability) feature.
If you are unable to use that, please email [email protected]. We will aim to respond within 3 business days.
Step 4: Disclosure Expectations
Be clear about what happens after the report.
## Disclosure Policy
We follow a 90-day disclosure policy. We will work with you to ensure a fix is developed and deployed. We ask that you do not disclose the vulnerability publicly until we have released a patch.
Not read yet
Why "Security Through Obscurity" is a Myth
Many developers believe that if they don't have a SECURITY.md file, they are "hidden" from hackers. This is known as "security through obscurity," and it is a dangerous fallacy. Automated scanners are constantly probing the internet for public repositories. If your project has a flaw, it will be found, regardless of whether you have a policy file.
By having a SECURITY.md file, you are not inviting attacks; you are preparing for the inevitable. You are shifting the balance of power from the attacker to the maintainer. When a researcher finds a bug, they have to choose: do they report it to you, or do they exploit it? By making the reporting process easy, professional, and welcoming, you make it significantly more likely that they will choose the ethical path.
Summary of Key Takeaways
To ensure your repository is well-prepared for security challenges, remember these core principles:
- Visibility is Key: A
SECURITY.mdfile is essential for establishing a clear, professional channel for reporting vulnerabilities. It is the first place a responsible researcher will look. - Use GitHub's Native Tools: Private Vulnerability Reporting and Security Advisories are powerful, built-in features that simplify the entire security workflow. Use them instead of reinventing the wheel with email.
- Clarity Over Complexity: Keep your policy simple. State what is supported, how to report, and what the researcher can expect in terms of a response.
- Maintenance is Mandatory: A security policy is a living document. Review it periodically to ensure contact information and version support status are accurate.
- Build Relationships: Treat security researchers as partners, not adversaries. Acknowledging their work and maintaining a positive, professional relationship will benefit your project for years.
- Integrate Security into the Workflow: Security is not just a document; it is a set of practices. Use automated tools like Dependabot and secret scanning to catch issues before they reach your users.
- Proactive Disclosure: When a vulnerability is found, own it. Communicate clearly, provide a fix, and publish a Security Advisory to protect the wider ecosystem that depends on your work.
By implementing these practices, you are doing more than just protecting your own repository; you are contributing to the overall health and security of the open-source community. Security is a team sport, and your SECURITY.md file is the invitation for your community to join that team.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
- What is Version Control
- What is Version Control Quiz5q
- Benefits of Version Control
- Benefits of Version Control Quiz5q
- Introduction to Git
- Introduction to Git Quiz5q
- Git vs GitHub Differences
- Git vs GitHub Differences Quiz5q
- Understanding Repositories
- Understanding Repositories Quiz5q
- Commits and Commit History
- Commits and Commit History Quiz5q
- Branches and Branching Strategies
- Branches and Branching Strategies Quiz5q
- GitHub Accounts and Profiles
- GitHub Accounts and Profiles Quiz5q
- GitHub Organizations
- GitHub Organizations Quiz5q
- GitHub Enterprise Options
- GitHub Enterprise Options Quiz5q
- GitHub Flow for Collaboration
- GitHub Flow for Collaboration Quiz5q
- Markdown Basics
- Markdown Basics Quiz5q
- GitHub Desktop Application
- GitHub Desktop Application Quiz5q
- GitHub Mobile
- GitHub Mobile Quiz5q
- Repository Structure Overview
- Repository Structure Overview Quiz5q
- README Files Best Practices
- README Files Best Practices Quiz5q
- LICENSE Files and Open Source
- LICENSE Files and Open Source Quiz5q
- CONTRIBUTING Guidelines
- CONTRIBUTING Guidelines Quiz5q
- CODEOWNERS File
- CODEOWNERS File Quiz5q
- SECURITY Policy Files
- SECURITY Policy Files Quiz5q
- Creating Repositories
- Creating Repositories Quiz5q
- Repository Templates
- Repository Templates Quiz5q
- Managing Files in Repositories
- Managing Files in Repositories Quiz5q
- Repository Insights and Metrics
- Repository Insights and Metrics Quiz5q
- Stars and Feature Previews
- Stars and Feature Previews Quiz5q
- Dependency Insights
- Dependency Insights Quiz5q
- Introduction to Issues
- Introduction to Issues Quiz5q
- Pull Requests Fundamentals
- Pull Requests Fundamentals Quiz5q
- GitHub Discussions
- GitHub Discussions Quiz5q
- Linking PRs to Issues
- Linking PRs to Issues Quiz5q
- Issue and PR Templates
- Issue and PR Templates Quiz5q
- Filters and Assignments
- Filters and Assignments Quiz5q
- Introduction to GitHub Actions
- Introduction to GitHub Actions Quiz5q
- GitHub Actions Components
- GitHub Actions Components Quiz5q
- Introduction to GitHub Copilot
- Introduction to GitHub Copilot Quiz5q
- Copilot Agents and Agent Mode
- Copilot Agents and Agent Mode Quiz5q
- Multi-Model Support in Copilot
- Multi-Model Support in Copilot Quiz5q
- Copilot Plans Comparison
- Copilot Plans Comparison Quiz5q
- Introduction to GitHub Projects
- Introduction to GitHub Projects Quiz5q
- Project Layout Options
- Project Layout Options Quiz5q
- Configuring Projects
- Configuring Projects Quiz5q
- Labels and Milestones
- Labels and Milestones Quiz5q
- Project Workflows
- Project Workflows Quiz5q
- Saved Replies and Assignees
- Saved Replies and Assignees Quiz5q
- Project Insights and Analytics
- Project Insights and Analytics Quiz5q
- Two-Factor Authentication
- Two-Factor Authentication Quiz5q
- Passkeys for Authentication
- Passkeys for Authentication Quiz5q
- Repository Access Permissions
- Repository Access Permissions Quiz5q
- Organization Roles
- Organization Roles Quiz5q
- Enterprise Managed Users
- Enterprise Managed Users Quiz5q
- Copilot Policy Management
- Copilot Policy Management Quiz5q
- Benefits of Open Source
- Benefits of Open Source Quiz5q
- GitHub Sponsors
- GitHub Sponsors Quiz5q
- Supporting Open Source Projects
- Supporting Open Source Projects Quiz5q
- Following Users and Organizations
- Following Users and Organizations Quiz5q
- GitHub Marketplace
- GitHub Marketplace Quiz5q
- InnerSource Principles
- InnerSource Principles Quiz5q
Spend your points to unlock exam-style practice questions
Spend points to unlock GH-900 exam-style practice questions.
Practice for GH-900