generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 185
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedinternalPRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)
Description
Summary
Multiple GitHub Actions workflows in this repository have security code scanning alerts related to token permissions. There are 6 open alerts across 6 workflow files related to permission configuration:
| Alert | Rule | Severity | File |
|---|---|---|---|
| #239 | githubactions:S8264 |
Low | reusable-run-linting-check-and-unit-tests.yml |
| #238 | githubactions:S8234 |
Low | ossf_scorecard.yml |
| #237 | githubactions:S8264 |
Low | quality_check.yml |
| #236 | githubactions:S8264 |
Low | publish_layer.yml |
| #235 | githubactions:S8264 |
Low | layers_partitions.yml |
| #233 | TokenPermissionsID |
High | layers_partitions_deploy.yml |
The alerts fall into two categories:
- S8264: Read permissions defined at workflow level instead of job level (4 alerts)
- S8234/TokenPermissionsID: Overly broad permission declarations (2 alerts)
Why is this needed?
- Security best practice: Following the principle of least privilege reduces attack surface if a workflow is compromised
- OSSF Scorecard compliance: Proper permission configuration contributes to a higher security score
- Defense in depth: Ensures new jobs fail safely (no permissions) rather than inheriting potentially unnecessary access
- CWE-266 compliance: Addresses "Incorrect Privilege Assignment" vulnerability class
Which area does this relate to?
Automation
Solution
Apply a two-layer permission strategy that satisfies both SonarCloud and OSSF Scorecard requirements:
1. Set restrictive top-level permissions
permissions: {} # Disables all permissions at workflow levelPer GitHub docs, this "disables permissions for all available scopes."
2. Declare permissions at each job level
jobs:
example-job:
permissions:
contents: read # Only grant what this specific job needs
runs-on: ubuntu-latestJob-level permissions override workflow-level, so each job gets exactly what it declares.
Files to update:
.github/workflows/reusable-run-linting-check-and-unit-tests.yml.github/workflows/ossf_scorecard.yml.github/workflows/quality_check.yml.github/workflows/publish_layer.yml.github/workflows/layers_partitions.yml.github/workflows/layers_partitions_deploy.yml
Benefits:
| Requirement | Result |
|---|---|
| OSSF Scorecard | 10/10 - Top-level permissions defined and restrictive |
| SonarCloud S8264 | Resolved - Read permissions at job level |
| SonarCloud S8234 | Resolved - No read-all/write-all at workflow level |
Acknowledgment
- This request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedinternalPRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)
Type
Projects
Status
Shipped