Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
chore(ci): add security baseline (SECURITY.md, audit, CodeQL, dependabot, concurrency) #2306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 9.x
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
chore(ci): add security baseline (SECURITY.md, audit, CodeQL, dependabot, concurrency) #2306
Changes from all commits
ca20015File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: ruflin/Elastica
Length of output: 216
🌐 Web query:
GitHub Actions workflow syntax permissions contents read job permissions actions set permissions for GITHUB_TOKEN💡 Result:
In GitHub Actions, you can configure the permissions granted to the GITHUB_TOKEN using the permissions key in your workflow file [1][2]. This allows you to follow the principle of least privilege by granting only the minimum access required for your jobs [2][3]. Permissions can be defined at two levels: 1. Workflow level: If specified at the top level of the YAML file, the permissions apply to all jobs within the workflow [1][4]. 2. Job level: If specified within a specific job, these permissions override any workflow-level settings for that job [1][4]. When you use the permissions key, any permissions not explicitly listed are set to none [1][3]. For example, if you set only contents: read, all other permissions (such as actions, issues, or packages) will have no access [1][4][3]. Example syntax for setting contents: read: jobs: job_id: runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@v4 The contents: read setting is commonly used to allow the workflow to clone or fetch the repository code [5][6]. If your workflow requires additional actions, such as pushing changes or creating releases, you must explicitly set the necessary permissions to write [6]. Key points to remember: - write permissions include read permissions [1]. - If you do not define the permissions key, GitHub applies the default permissions for the repository [6]. - Pull requests from public forks are a special case; they receive a read-only token regardless of these settings [3]. For a complete list of available scopes (such as actions, checks, deployments, packages, etc.), refer to the official GitHub Actions workflow syntax documentation [1][3].
Citations:
🏁 Script executed:
Repository: ruflin/Elastica
Length of output: 7313
Declare minimal permissions for the audit job.
continuous-integration.yamlhas no workflow-levelpermissions, so this job inherits the repository’s defaultGITHUB_TOKENpermissions while executing external actions. Setcontents: readhere; unlisted permissions will benone.🧰 Tools
🪛 zizmor (1.28.0)
[warning] 9-29: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents
Source: Linters/SAST tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: ruflin/Elastica
Length of output: 4246
🌐 Web query:
GitHub Actions secure use use full commit SHA branch tag mutable action security💡 Result:
To secure GitHub Actions workflows against supply chain attacks, it is considered a critical best practice to pin all actions to a full-length (40-character) commit SHA [1][2][3][4][5]. Why Commit SHAs are Required for Security: - Immutability: Unlike branch names (e.g.,
@main,@master) or version tags (e.g.,@v4), which are mutable pointers that can be moved or force-pushed to different commits by anyone with write access to the action's repository, a full commit SHA is cryptographically immutable [1][3][6][7]. - Mitigation of "Retargeting" Attacks: Using mutable references leaves your workflows vulnerable to malicious code injection if an action's repository or maintainer account is compromised [8][7][9]. An attacker can update an existing tag to point to malicious code, which would then be automatically executed by your workflows without any changes to your YAML files [2][6][7]. Pinning to a SHA prevents this entirely [2][3][10]. - Organizational Enforcement: GitHub now supports organization-level policies that can enforce full commit SHA pinning [11][2][9]. When enabled, workflows using mutable references will fail, ensuring compliance across an entire organization [11][2]. Best Practices for Implementation: - Pinning Format: Always use the full 40-character commit SHA [1][3]. - Maintain Readability: To maintain clarity and support automated updates, include the human-readable version tag as a trailing comment in your workflow file [2][8][7]. Example: - uses: actions/checkout@b4ffde6 # v4.1.1 - Automate Updates: Use dependency management tools like Renovate or Dependabot to automate the maintenance of these pinned SHAs [2][3][8][7]. These tools can be configured to track the associated tags and open pull requests when new versions are released, allowing you to update your pins intentionally [2][8][10]. - Transitive Security: Be aware that the security policy applies to the entire dependency tree. If you maintain an action that uses other actions internally, ensure those sub-actions are also pinned to full commit SHAs [11][9]. - Adoption Cooldowns: To further reduce risk, some organizations adopt a "cooldown" period (e.g., 7-14 days) before updating to new pinned versions of actions, which helps catch malicious releases that are often detected quickly [9].Citations:
🌐 Web query:
docs.github.com actions reference security hard coding commit SHA Actions💡 Result:
Pinning GitHub Actions to a full-length commit SHA is a primary security best practice recommended by GitHub to ensure the immutability of the code executed in your workflows [1][2]. Key security considerations include: - Why it is required: Using mutable references like tags (e.g.,
@v1,@v4) or branch names (e.g.,@main) allows the underlying code to be changed or updated silently, posing a supply-chain risk if an action's repository is compromised or a tag is moved [1][3][2]. Pinning to a full 40-character commit SHA ensures that the exact code you audited is the code that runs [4][2]. - Policy Enforcement: GitHub allows administrators to enforce SHA pinning at the repository, organization, and enterprise levels [1][5][6]. When this policy is enabled, any workflow attempting to use an action referenced by a mutable tag or branch will fail [7]. This policy applies to the entire action dependency tree, meaning any internal sub-actions referenced by an action must also be pinned to a SHA [7]. - Managing Updates: While SHA pinning provides immutability, it does not prevent you from keeping your actions up to date. The recommended practice is to pin the action to a full-length commit SHA while keeping the human-readable version as a comment (e.g., uses: actions/checkout@a1b2c3d4e5... # v4.2.0) [3][4]. Tools like Dependabot can track these version comments and automatically open pull requests to update the pinned SHA when a new release is available, providing both security and ease of maintenance [3][5][4]. - Warning against short SHAs: You should always use the full-length (40-character) commit SHA [1][4]. Shortened SHAs are insecure because they are vulnerable to collision attacks where a malicious user could craft a commit that matches the short SHA, leading to ambiguous or compromised references [2]. For detailed configuration steps, refer to GitHub's documentation on securing your workflows [1][6].Citations:
Pin the actions to immutable commit SHAs.
.github/workflows/continuous-integration.yamlpins the audit job to mutable tags (actions/checkout@v4,shivammathur/setup-php@v2, andramsey/composer-install@v3), so the job can run changed code without workflow changes. Use full 40-character commit SHAs with human-readable version comments, and keep Dependabot configured to update those pins.🧰 Tools
🪛 GitHub Check: CodeQL
[warning] 17-17: Unpinned tag for a non-immutable Action in workflow or composite action
Unpinned 3rd party Action 'Continuous integration' step Uses Step uses 'shivammathur/setup-php' with ref 'v2', not a pinned commit hash
[warning] 24-24: Unpinned tag for a non-immutable Action in workflow or composite action
Unpinned 3rd party Action 'Continuous integration' step Uses Step uses 'ramsey/composer-install' with ref 'v3', not a pinned commit hash
🪛 zizmor (1.28.0)
[warning] 13-14: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Source: Linters/SAST tools
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the SECURITY.md file
Uh oh!
There was an error while loading. Please reload this page.