-
Notifications
You must be signed in to change notification settings - Fork 54
Cryptographic Validation For Authenticated Variables #327
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
Draft
Flickdm
wants to merge
16
commits into
microsoft:main
Choose a base branch
from
Flickdm:feature/auth_var/cryptographic_validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f8b019f
auth_var_tool: add cryptographic verification for efi authenticated v…
Flickdm 6cf0316
auth_var_tool: updating describe to print the ascii strings
Flickdm 7488cf8
auth_var_tool: ruff updates
Flickdm 2b63d08
auth_var_tool: minor updates
Flickdm 5784321
Rename validate_kek_folder.py to validate_kek.py and add single file …
Flickdm c97c8b0
Add CI workflow to validate KEK updates in pull requests
Flickdm cc0ae88
Update scripts/auth_var_tool.py
Flickdm 6c4c14b
Merge branch 'microsoft:main' into feature/auth_var/cryptographic_val…
Flickdm 4efa885
Update scripts/auth_var_tool.py
Flickdm 2599ebd
Update scripts/validate_kek.py
Flickdm 4b53fcf
Update scripts/auth_var_tool.py
Flickdm c689731
Update scripts/auth_var_tool.py
Flickdm b84bdd0
Update scripts/auth_var_tool.py
Flickdm 62b3eec
Update scripts/validate_kek.py
Flickdm bb2122b
Update scripts/validate_kek.py
Flickdm d573d84
Update scripts/validate_kek.py
Flickdm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # This workflow validates KEK update files in pull requests to ensure they have | ||
| # valid cryptographic signatures and expected payloads before merging. | ||
| # | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: BSD-2-Clause-Patent | ||
| name: Validate KEK Updates | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| paths: | ||
| - 'PostSignedObjects/KEK/**/*.bin' | ||
| - 'PreSignedObjects/KEK/**/*.bin' | ||
|
|
||
| jobs: | ||
| validate-kek: | ||
| name: Validate KEK Update Files | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout PR | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Need full history to compare with base branch | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: 3.12 | ||
| cache: 'pip' | ||
| cache-dependency-path: pip-requirements.txt | ||
|
|
||
| - name: Install Pip Dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r pip-requirements.txt | ||
|
|
||
| - name: Get Changed KEK Files | ||
| id: changed-files | ||
| run: | | ||
| # Get list of changed .bin files in KEK directories | ||
| git fetch origin ${{ github.base_ref }} | ||
| CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}...HEAD | grep -E '(PostSignedObjects|PreSignedObjects)/KEK/.*\.bin$' || echo "") | ||
|
|
||
| if [ -z "$CHANGED_FILES" ]; then | ||
| echo "No KEK files changed" | ||
| echo "has_changes=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "Changed KEK files:" | ||
| echo "$CHANGED_FILES" | ||
| echo "has_changes=true" >> $GITHUB_OUTPUT | ||
| # Save changed files to a temporary file | ||
| echo "$CHANGED_FILES" > changed_kek_files.txt | ||
| fi | ||
|
|
||
| - name: Validate Changed KEK Files | ||
| if: steps.changed-files.outputs.has_changes == 'true' | ||
| run: | | ||
| VALIDATION_FAILED=0 | ||
| VALIDATION_RESULTS_DIR="kek_validation_results" | ||
| mkdir -p "$VALIDATION_RESULTS_DIR" | ||
|
|
||
| echo "## KEK Validation Results" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| while IFS= read -r file; do | ||
| if [ -f "$file" ]; then | ||
| echo "Validating: $file" | ||
| BASENAME=$(basename "$file" .bin) | ||
| OUTPUT_JSON="$VALIDATION_RESULTS_DIR/${BASENAME}_validation.json" | ||
|
|
||
| # Run validation and capture exit code | ||
| if python scripts/validate_kek.py "$file" -o "$OUTPUT_JSON" -q; then | ||
| # Parse JSON to check both signature and payload | ||
| SIGNATURE_VALID=$(jq -r '.result.valid' "$OUTPUT_JSON") | ||
| PAYLOAD_VALID=$(jq -r '.result.payload_hash_valid' "$OUTPUT_JSON") | ||
|
|
||
| if [ "$SIGNATURE_VALID" = "true" ] && [ "$PAYLOAD_VALID" = "true" ]; then | ||
| echo "✅ **PASS**: \`$file\`" >> $GITHUB_STEP_SUMMARY | ||
| echo " - Cryptographic Signature: ✅ VALID" >> $GITHUB_STEP_SUMMARY | ||
| echo " - Expected Payload: ✅ True" >> $GITHUB_STEP_SUMMARY | ||
| elif [ "$SIGNATURE_VALID" = "true" ] && [ "$PAYLOAD_VALID" = "false" ]; then | ||
| echo "⚠️ **WARNING**: \`$file\`" >> $GITHUB_STEP_SUMMARY | ||
| echo " - Cryptographic Signature: ✅ VALID" >> $GITHUB_STEP_SUMMARY | ||
| echo " - Expected Payload: ⚠️ False (non-standard payload)" >> $GITHUB_STEP_SUMMARY | ||
| PAYLOAD_HASH=$(jq -r '.result.payload_hash' "$OUTPUT_JSON") | ||
| echo " - Payload Hash: \`$PAYLOAD_HASH\`" >> $GITHUB_STEP_SUMMARY | ||
| # Don't fail on payload mismatch, just warn | ||
| else | ||
| echo "❌ **FAIL**: \`$file\`" >> $GITHUB_STEP_SUMMARY | ||
| echo " - Cryptographic Signature: ❌ INVALID" >> $GITHUB_STEP_SUMMARY | ||
| echo " - Expected Payload: $([ "$PAYLOAD_VALID" = "true" ] && echo "✅ True" || echo "⚠️ False")" >> $GITHUB_STEP_SUMMARY | ||
| VALIDATION_FAILED=1 | ||
| fi | ||
| else | ||
| echo "❌ **FAIL**: \`$file\` - Validation script failed" >> $GITHUB_STEP_SUMMARY | ||
| VALIDATION_FAILED=1 | ||
| fi | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| done < changed_kek_files.txt | ||
|
|
||
| # Upload validation results as artifact | ||
| if [ -d "$VALIDATION_RESULTS_DIR" ] && [ "$(ls -A $VALIDATION_RESULTS_DIR)" ]; then | ||
| echo "Uploading validation results..." | ||
| fi | ||
|
|
||
| # Exit with error if any validation failed | ||
| if [ $VALIDATION_FAILED -eq 1 ]; then | ||
| echo "::error::One or more KEK files have invalid cryptographic signatures" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Upload Validation Results | ||
| if: steps.changed-files.outputs.has_changes == 'true' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: kek-validation-results | ||
| path: kek_validation_results/ | ||
| retention-days: 30 | ||
|
|
||
| - name: Comment on PR | ||
| if: steps.changed-files.outputs.has_changes == 'true' && failure() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: '❌ **KEK Validation Failed**\n\nOne or more KEK update files have invalid cryptographic signatures. Please review the validation results in the workflow run details.' | ||
| }) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.