feat(security): add dependency confusion pre-commit hook + weekly audit CI#350
feat(security): add dependency confusion pre-commit hook + weekly audit CI#350imran-siddique merged 14 commits intomicrosoft:mainfrom
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add EU AI Act, Colorado AI Act, and GPAI obligations timeline with AGT coverage mapping. Reference Microsoft Purview DSPM for AI as complementary data governance layer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Scorecard API rejects workflows with write permissions at the workflow level. id-token: write and security-events: write must be scoped to the job level only. Restores permissions: read-all at workflow level while keeping job-level write permissions intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ft#324) Add Google-style docstrings with Args, Returns, Raises, Attributes, and Example sections to MCPMessageType, MCPAdapter, and MCPServer classes. Also enhances docstrings for key methods including handle_message, _handle_tools_call, _handle_resources_read, and _map_tool_to_action. Fixes microsoft#316
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
…s (dependency confusion) (microsoft#325) - Replace !pip install agent-os with !pip install -e ../.. in all 6 notebooks; agent-os is not on PyPI and installing it from PyPI is a dependency confusion vector - Replace zendesk-sdk/freshdesk-sdk with zenpy/freshdesk (the real published SDKs) in customer-service/requirements.txt - Remove hashlib-compat from healthcare-hipaa/requirements.txt; hashlib is stdlib and hashlib-compat is not a real PyPI package
…stall agent-os with agent-os-kernel Replace all remaining instances of `pip install agent-os` (unregistered on PyPI) with `pip install agent-os-kernel` (the actual package) across docs, examples, TypeScript extensions, CLI source, tests, and SVG assets. Also fixes `pip install emk` references to point to `agent-os-kernel[full]` since emk is a submodule, not a standalone PyPI package. Completes the fix started in PR microsoft#325 which only covered notebooks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dify 65K→133K, AutoGen 42K→55K, CrewAI 28K→46K, Semantic Kernel 24K→27K, LangGraph 24K→27K, Haystack 22K→24K, Agent Framework 7.6K→8K. Added star counts for OpenAI Agents SDK (20K) and Google ADK (18K). Sorted by stars descending. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…it CI - scripts/check_dependency_confusion.py: Pre-commit hook that scans for pip install commands referencing unregistered PyPI packages. Maintains an allowlist of known registered packages. - .github/workflows/weekly-security-audit.yml: Weekly CI job running dependency confusion scan, security skills scan, and weak crypto check. Uploads reports as artifacts with 90-day retention. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Summary
This pull request introduces a pre-commit hook and a weekly CI job to detect and prevent dependency confusion attacks, weak cryptography usage, and other security issues. The changes are a step in the right direction for improving the security posture of the repository. However, there are some areas that require attention to ensure correctness, security, and maintainability.
🔴 CRITICAL
-
Potential False Negatives in Dependency Confusion Detection:
- The
extract_package_namesfunction does not handle all possible cases ofpip installsyntax. For example:- It does not account for cases where package names are specified with environment variables (e.g.,
pip install $PACKAGE_NAME). - It does not handle cases where package names are specified in a requirements file with complex version specifiers (e.g.,
package[extra]>=1.0,<2.0).
- It does not account for cases where package names are specified with environment variables (e.g.,
- Action: Use a more robust parser for
pip installcommands, such as leveragingpip's own internal parsing logic or a library likepackaging.
- The
-
Weak Cryptography Check:
- The weak cryptography check only looks for
hashlib.md5andhashlib.sha1but does not account for other weak cryptographic algorithms or libraries (e.g.,hmac.new(..., digestmod=hashlib.md5)or custom implementations of MD5/SHA1). - Action: Expand the weak cryptography check to include other weak algorithms and patterns. Consider using a static analysis tool like
banditfor this purpose.
- The weak cryptography check only looks for
-
Pickle Usage Check:
- The pickle usage check only looks for
pickle.loadbut does not account for other unsafe methods likepickle.loadsor alternative libraries likecPickle. - Action: Expand the check to include all unsafe deserialization methods and libraries.
- The pickle usage check only looks for
-
Lack of Validation for
REGISTERED_PACKAGES:- The
REGISTERED_PACKAGESlist is manually maintained, which introduces the risk of human error or outdated entries. - Action: Implement an automated mechanism to periodically validate the
REGISTERED_PACKAGESlist against the PyPI registry to ensure it remains up-to-date.
- The
🟡 WARNING
-
Backward Compatibility:
- The addition of the pre-commit hook could potentially disrupt existing workflows if developers are not aware of its presence or if it blocks commits due to false positives.
- Action: Clearly document the pre-commit hook in the repository's
CONTRIBUTING.mdfile and provide instructions for bypassing the hook if necessary (e.g.,git commit --no-verify).
-
Potential Breaking Changes in CI:
- The weekly security audit CI job could fail due to false positives in the dependency confusion or security scans, which might block other workflows or create noise.
- Action: Ensure that the CI job does not block other workflows and that false positives are minimized. Consider running the job in a separate pipeline or as an informational job.
💡 SUGGESTIONS
-
Improve Logging and Error Reporting:
- The
check_dependency_confusion.pyscript could benefit from more detailed logging, such as indicating which files are being scanned and providing context for findings. - Action: Add logging statements to indicate progress and provide more context for findings.
- The
-
Test Coverage:
- There is no evidence of test coverage for the
check_dependency_confusion.pyscript or the new CI jobs. - Action: Add unit tests for the
check_dependency_confusion.pyscript and integration tests for the CI workflows to ensure they function as expected.
- There is no evidence of test coverage for the
-
Use of
continue-on-error:- The
security-skills-scanjob usescontinue-on-error: true, which could lead to missed issues if the job fails silently. - Action: Consider removing
continue-on-errorand instead handle errors explicitly within the script to ensure that issues are surfaced appropriately.
- The
-
Dependency Management:
- The
pip installcommands in the CI workflows do not pin dependency versions, which could lead to non-deterministic behavior. - Action: Pin the versions of all dependencies in the CI workflows to ensure reproducibility.
- The
-
Documentation:
- The new scripts and workflows are not documented in the repository.
- Action: Update the repository's documentation to include details about the new pre-commit hook and weekly security audit CI job.
-
Security Skills Scan:
- The
security_scan.pyscript is not included in the diff, so its implementation cannot be reviewed. However, it is critical to ensure that it adheres to best practices for security scanning. - Action: Provide the implementation of
security_scan.pyfor review.
- The
-
Performance Optimization:
- The
check_dependency_confusion.pyscript scans all files matching certain extensions, which could be inefficient for large repositories. - Action: Optimize the file scanning process by limiting it to relevant directories or using a more efficient file traversal method.
- The
Final Recommendation
- Address the critical issues to ensure the correctness and security of the changes.
- Consider the warnings to avoid potential disruptions to existing workflows.
- Implement the suggestions to improve the maintainability, performance, and usability of the new features.
Once the critical issues are resolved and the warnings are addressed, this pull request can be approved.
🤖 AI Agent: security-scanner — Security Review of PR: feat(security): add dependency confusion pre-commit hook + weekly audit CISecurity Review of PR: feat(security): add dependency confusion pre-commit hook + weekly audit CIFindings:1. Dependency Confusion Detection Logic
2. Pre-commit Hook Installation Instructions
3. Potential Credential Exposure in Logs
4. Race Condition in Dependency Confusion Check
5. Lack of Comprehensive Dependency Scanning
6. Weak Cryptography Check
7. Deserialization Check
8. Hardcoded Dependencies in CI
Summary of Findings:
Overall Assessment:This PR introduces valuable security measures to detect dependency confusion, weak cryptography, and unsafe deserialization. However, there are some areas for improvement to enhance the robustness of the checks and reduce the risk of bypasses or false negatives. Addressing the identified issues will significantly strengthen the security posture of the repository. |
Proactive security tooling from audit recommendations: