-
Notifications
You must be signed in to change notification settings - Fork 100
ci: integrate SafeDep PMG on all workflow jobs #340
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: master
Are you sure you want to change the base?
Changes from all commits
1f71d49
4c51862
a244ee6
a6fa245
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,14 @@ jobs: | |||||||
| runs-on: ubuntu-latest | ||||||||
| steps: | ||||||||
| - uses: actions/checkout@v3 | ||||||||
|
|
||||||||
| - name: Setup PMG proxy | ||||||||
| id: pmg-setup | ||||||||
| uses: safedep/pmg@v1 | ||||||||
| with: | ||||||||
| server-mode: true | ||||||||
| api-key: ${{ secrets.PMG_PUBLIC_REPOS_TOKEN }} | ||||||||
| tenant-id: ${{ secrets.PMG_TENANT_ID }} | ||||||||
| - name: Set up Python 3 | ||||||||
| uses: actions/setup-python@v3 | ||||||||
| with: | ||||||||
|
|
@@ -31,12 +39,28 @@ jobs: | |||||||
| with: | ||||||||
| name: dist | ||||||||
| path: dist/ | ||||||||
|
|
||||||||
| - name: Enforce PMG policy | ||||||||
| if: always() | ||||||||
| run: | | ||||||||
| if [ "${{ steps.pmg-setup.outcome }}" = "success" ]; then | ||||||||
| pmg proxy stop --fail-on-violation | ||||||||
| else | ||||||||
| pmg proxy stop || true | ||||||||
| fi | ||||||||
| test: | ||||||||
| name: Test Coverage | ||||||||
| needs: build | ||||||||
| runs-on: ubuntu-latest | ||||||||
| steps: | ||||||||
| - uses: actions/checkout@v3 | ||||||||
| - name: Setup PMG proxy | ||||||||
| id: pmg-setup | ||||||||
| uses: safedep/pmg@v1 | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semgrep identified an issue in your code: The More details about this
A plausible attack would be:
Because the reference is To resolve this comment: ✨ Commit fix suggestion
Suggested change
View step-by-step instructions
💬 Ignore this findingLeave a nosemgrep comment directly above or at the end of line 50 like so Take care to validate that this is not a true positive finding before ignoring it. You can view more details about this finding in the Semgrep AppSec Platform. |
||||||||
| with: | ||||||||
| server-mode: true | ||||||||
| api-key: ${{ secrets.PMG_PUBLIC_REPOS_TOKEN }} | ||||||||
| tenant-id: ${{ secrets.PMG_TENANT_ID }} | ||||||||
| - name: Set up Python 3 | ||||||||
| uses: actions/setup-python@v3 | ||||||||
| with: | ||||||||
|
|
@@ -53,13 +77,28 @@ jobs: | |||||||
| python -m coverage xml | ||||||||
| - name: Upload coverage to Codecov | ||||||||
| uses: codecov/codecov-action@v3 | ||||||||
| - name: Enforce PMG policy | ||||||||
| if: always() | ||||||||
| run: | | ||||||||
| if [ "${{ steps.pmg-setup.outcome }}" = "success" ]; then | ||||||||
| pmg proxy stop --fail-on-violation | ||||||||
| else | ||||||||
| pmg proxy stop || true | ||||||||
| fi | ||||||||
|
|
||||||||
| publish: | ||||||||
| if: startsWith(github.ref, 'refs/tags/v') | ||||||||
| needs: test | ||||||||
| runs-on: ubuntu-latest | ||||||||
| steps: | ||||||||
| - uses: actions/checkout@v2 | ||||||||
| - name: Setup PMG proxy | ||||||||
| id: pmg-setup | ||||||||
| uses: safedep/pmg@v1 | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semgrep identified an issue in your code: The More details about this
The same mutable action reference is also used in the test job, where it executes during ordinary workflow runs and can access the configured SafeDep secrets. To resolve this comment: ✨ Commit fix suggestion
Suggested change
View step-by-step instructions
💬 Ignore this findingLeave a nosemgrep comment directly above or at the end of line 81 like so Take care to validate that this is not a true positive finding before ignoring it. You can view more details about this finding in the Semgrep AppSec Platform. |
||||||||
| with: | ||||||||
| server-mode: true | ||||||||
| api-key: ${{ secrets.PMG_PUBLIC_REPOS_TOKEN }} | ||||||||
| tenant-id: ${{ secrets.PMG_TENANT_ID }} | ||||||||
| - name: Download all workflow run artifacts | ||||||||
| uses: actions/download-artifact@v4 | ||||||||
| with: | ||||||||
|
|
@@ -78,4 +117,12 @@ jobs: | |||||||
| env: | ||||||||
| TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | ||||||||
| TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | ||||||||
| - name: Enforce PMG policy | ||||||||
| if: always() | ||||||||
| run: | | ||||||||
| if [ "${{ steps.pmg-setup.outcome }}" = "success" ]; then | ||||||||
| pmg proxy stop --fail-on-violation | ||||||||
| else | ||||||||
| pmg proxy stop || true | ||||||||
| fi | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,13 @@ jobs: | |||||||
|
|
||||||||
| steps: | ||||||||
| - uses: actions/checkout@v2 | ||||||||
| - name: Setup PMG proxy | ||||||||
| id: pmg-setup | ||||||||
| uses: safedep/pmg@v1 | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semgrep identified an issue in your code: The More details about thisThe A plausible attack would be:
Because To resolve this comment: ✨ Commit fix suggestion
Suggested change
View step-by-step instructions
💬 Ignore this findingLeave a nosemgrep comment directly above or at the end of line 25 like so Take care to validate that this is not a true positive finding before ignoring it. You can view more details about this finding in the Semgrep AppSec Platform. |
||||||||
| with: | ||||||||
| server-mode: true | ||||||||
| api-key: ${{ secrets.PMG_PUBLIC_REPOS_TOKEN }} | ||||||||
| tenant-id: ${{ secrets.PMG_TENANT_ID }} | ||||||||
| - name: Set up Python | ||||||||
| uses: actions/setup-python@v2 | ||||||||
| - name: Install dependencies | ||||||||
|
|
@@ -31,3 +38,11 @@ jobs: | |||||||
| python3 setup.py install | ||||||||
| - name: Run Tests | ||||||||
| run: python3 -m unittest | ||||||||
| - name: Enforce PMG policy | ||||||||
| if: always() | ||||||||
| run: | | ||||||||
| if [ "${{ steps.pmg-setup.outcome }}" = "success" ]; then | ||||||||
| pmg proxy stop --fail-on-violation | ||||||||
| else | ||||||||
| pmg proxy stop || true | ||||||||
| fi | ||||||||
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.
Semgrep identified an issue in your code:
The build workflow executes
safedep/pmgthrough the mutablev1tag. If that tag is repointed, a future run can execute attacker-controlled action code with the SafeDep API key and tenant ID.More details about this
uses: safedep/pmg@v1runs thesafedep/pmgaction from the mutablev1tag. The tag can be moved by the action owner—or by an attacker who compromises that repository—so a later workflow run may execute different code without any change to this repository.A plausible attack is:
safedep/pmgrepository or its release process and repointsv1to a malicious commit.masterstarts thebuildjob, which executes that new commit atStart PMG proxy.${{ secrets.SAFEDEP_API_KEY }}and${{ secrets.SAFEDEP_API_KEY }}/${{ secrets.SAFEDEP_API_KEY }}-adjacent workflow credentials through itswithinputs; malicious action code can read the suppliedapi-keyandtenant-idvalues and send them to an attacker-controlled server.python -m buildandtwinecommands. The stolen credentials could let the attacker access the SafeDep tenant or abuse its API from outside the workflow.To resolve this comment:
✨ Commit fix suggestion
View step-by-step instructions
v1reference with the full 40-character commit SHA for the intendedsafedep/pmgrelease:uses: safedep/pmg@<40-character-commit-sha> # v1safedep/pmgrepository and corresponds to the version currently required by this workflow.# v1, so the pinned commit’s intended release remains clear.💬 Ignore this finding
Leave a nosemgrep comment directly above or at the end of line 18 like so
// nosemgrep: yaml.github-actions.security.github-actions-mutable-action-tag.github-actions-mutable-action-tagTake care to validate that this is not a true positive finding before ignoring it.
Learn more about ignoring code, files and folders here.
You can view more details about this finding in the Semgrep AppSec Platform.