fix: migrate Rust crate publishing from cargo publish to ESRP Release#668
Conversation
Replace direct cargo publish (CARGO_REGISTRY_TOKEN) with the official ESRP Release pipeline (EsrpRelease@11 with contenttype: Rust). Per EngHub guidance (aka.ms/esrp-crates-io), all Microsoft Rust packages must publish through ESRP under the microsoft-oss-releases crates.io account for code signing, malware scanning, and archival. Pipeline changes: - Build stage: cargo package → copy .crate to workspace - Publish stage: EsrpRelease@11 replaces cargo publish - Uses shared ESRP config (no separate CRATES_IO_TOKEN needed) Also updates PUBLISHING.md to reflect ESRP for Rust. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Feedback for Pull Request: "fix: migrate Rust crate publishing from cargo publish to ESRP Release"
🔴 CRITICAL: Security Concerns
-
Pipeline Artifact Handling:
- The
.cratefiles are copied to the pipeline workspace ($(Pipeline.Workspace)/rust-packages) and later published via ESRP. Ensure that the workspace is isolated and not accessible by other jobs or stages in the pipeline. If the workspace is shared, malicious actors could tamper with the.cratefiles before ESRP processes them. - Action: Add explicit pipeline isolation or integrity checks (e.g., checksum validation) before invoking ESRP.
- The
-
ESRP Configuration Secrets:
- The ESRP task uses sensitive inputs such as
keyvaultname,signcertname, andclientid. Ensure these secrets are stored securely in Azure Key Vault or equivalent and are not exposed in pipeline logs. - Action: Confirm that
$(ESRP_KEYVAULT_NAME),$(ESRP_CERT_IDENTIFIER), and other secrets are securely managed and not hardcoded in the pipeline YAML.
- The ESRP task uses sensitive inputs such as
-
Malware Scanning:
- While ESRP performs malware scanning, there is no pre-ESRP validation of the
.cratefiles. If the.cratefiles are tampered with before ESRP processing, this could lead to malicious code being signed and published. - Action: Add a pre-ESRP step to verify the integrity of the
.cratefiles (e.g., hash comparison against a known good state).
- While ESRP performs malware scanning, there is no pre-ESRP validation of the
🟡 WARNING: Potential Breaking Changes
-
Crates.io Account Migration:
- The migration to the
microsoft-oss-releasesaccount changes the ownership of published crates. This could impact downstream consumers relying on the previous account for updates. - Action: Communicate this change clearly in release notes and documentation. Consider providing a transition guide for consumers.
- The migration to the
-
Yanking Crates:
- The removal of programmatic yanking via
cargo yankintroduces operational overhead (IcM incidents). This could delay critical security fixes requiring crate yanking. - Action: Work with the ESRP team to prioritize adding programmatic yanking support.
- The removal of programmatic yanking via
💡 SUGGESTIONS: Improvements
-
Pipeline Documentation:
- The updated
PUBLISHING.mdis clear but could benefit from a diagram showing the ESRP pipeline flow for Rust crates. Visual aids help onboard new contributors faster. - Action: Add a diagram illustrating the ESRP pipeline stages for Rust crate publishing.
- The updated
-
Checksum Validation:
- Enhance the pipeline by generating and validating checksums for
.cratefiles before publishing. This ensures file integrity and prevents tampering. - Action: Add a step to compute and validate SHA256 checksums for
.cratefiles.
- Enhance the pipeline by generating and validating checksums for
-
Dry Run Testing:
- The pipeline conditionally skips publishing when
dryRunis true. Consider adding a dry-run mode for ESRP to simulate the release process without actual publishing. - Action: Investigate ESRP's support for dry-run functionality and integrate it into the pipeline.
- The pipeline conditionally skips publishing when
-
Backward Compatibility:
- While the ESRP migration is necessary, ensure that the pipeline supports legacy publishing methods (
cargo publish) for emergency scenarios or backward compatibility. - Action: Add a fallback mechanism to allow manual
cargo publishif ESRP is unavailable.
- While the ESRP migration is necessary, ensure that the pipeline supports legacy publishing methods (
Summary
This pull request introduces a critical migration to ESRP Release for Rust crate publishing, aligning with Microsoft OSS guidelines. While the changes improve security and compliance, there are critical concerns around pipeline artifact handling and pre-ESRP validation. Addressing these issues will ensure the integrity and security of published crates. Additionally, breaking changes like account migration and yanking limitations should be communicated effectively to downstream consumers.
🤖 AI Agent: security-scanner — Security Review of PR: Migrate Rust Crate Publishing to ESRP ReleaseSecurity Review of PR: Migrate Rust Crate Publishing to ESRP ReleaseThis PR replaces the existing Findings1. 🔵 LOW: Removal of
|
| Finding | Severity | Recommendation |
|---|---|---|
Removal of CRATES_IO_TOKEN |
🔵 LOW | No action needed. Positive security improvement. |
| ESRP Configuration Validation | 🟡 MEDIUM | Ensure ESRP parameters are securely stored and immutable. |
Removal of Direct cargo publish |
🔵 LOW | No action needed. Positive security improvement. |
Lack of Verification for .crate Files |
🟠 HIGH | Add checksum verification for .crate files before uploading to ESRP. |
| Dependency on ESRP | 🔵 LOW | Regularly audit ESRP configurations and establish a fallback plan. |
| Documentation Updates | 🔵 LOW | Include instructions for verifying the authenticity of published crates. |
Final Assessment
This PR introduces significant security improvements by migrating to ESRP for Rust crate publishing. However, the lack of verification for .crate file integrity before uploading to ESRP is a notable gap that could be exploited by an attacker with access to the pipeline. Addressing this issue is critical to ensure the integrity of the published crates.
Overall Rating: 🟠 HIGH (due to the lack of .crate file verification).
Suggested Next Steps
- Implement
.cratefile checksum verification in the pipeline. - Secure ESRP configuration parameters and validate their integrity.
- Update documentation to include instructions for verifying published crate authenticity.
Let me know if you need further assistance!
Per EngHub guidance, all Microsoft Rust packages must publish through ESRP Release under the \microsoft-oss-releases\ crates.io account.
Changes
Docs