dotnet/skills Security Best Practices: Governance, Automation, and Runtime Hardening

The dotnet/skills repository enforces security through private vulnerability reporting via the Microsoft Security Response Center, automated PR scanning with pr-malicious-scan.agent, minimal-permission CI workflows, and embedded security checklists within skill plugins for MSBuild, NuGet, and .NET migration scenarios.

The dotnet/skills repository provides skill plugins that power automated agents for .NET development, handling sensitive operations like project file manipulation and external service integration. Because these capabilities carry inherent security risks, the repository embeds defense-in-depth measures across governance, continuous integration, and runtime layers. This guide examines the specific files, workflows, and code patterns that constitute the official dotnet/skills security best practices.

Responsible Disclosure and Governance

Security reporting in dotnet/skills follows a coordinated disclosure model centered on private channels. The SECURITY.md file at the repository root mandates that all vulnerability reports be submitted through the Microsoft Security Response Center (MSRC) rather than public GitHub issues. This policy prevents premature exposure of exploits and ensures proper triage by Microsoft’s security team.

Similarly, CONTRIBUTING.md reiterates this requirement, instructing contributors to follow the private-report process whenever they discover potential security issues during development. These governance documents establish the foundation for trust by ensuring sensitive findings remain confidential until patches are available.

CI/CD Pipeline Hardening

The repository implements security-hardened workflows that enforce the principle of least privilege across all automation. According to .github/agents/agentic-workflows.md, all GitHub Actions must use minimal permissions and explicit network access controls, preventing agents from over-provisioning credentials or accessing unnecessary external resources.

The .github/workflows/pr-malicious-scan.agent.md workflow provides automated detection by scanning every pull request diff for known security patterns. When the agent identifies suspicious changes—such as credential injections or malicious script embeddings—it automatically applies the pr-needs-security-review label to block merging until human verification occurs.

Additionally, .github/workflows/devops-health-check.md locks down the runtime environment by explicitly denying generic scripting languages including Python, Node.js, and Bash unless they are explicitly whitelisted for a specific task. This restriction prevents arbitrary code execution within the CI context.


# .github/workflows/security-label.yml

name: Security Review
on:
  pull_request_target:
    types: [opened, synchronize]

jobs:
  label:
    runs-on: ubuntu-latest
    steps:
      - name: Run PR malicious scan
        uses: ./ .github/workflows/pr-malicious-scan.agent.md
      - name: Apply security label if needed
        if: steps.pr-malicious-scan.outputs.security_issues != ''
        run: |
          gh pr edit ${{ github.event.pull_request.number }} \
            --add-label pr-needs-security-review

The workflow reuses the existing pr-malicious-scan.agent to surface security findings and programmatically adds the pr-needs-security-review label when potential threats are detected.

Skill-Level Security Controls

Each skill plugin embeds domain-specific security validations that execute during code generation and migration tasks.

MSBuild Project Auditing

The msbuild.agent documented in plugins/dotnet-msbuild/agents/msbuild.agent.md scans .csproj and .sln files for security anti-patterns and insecure property configurations. This agent runs during CI to flag dangerous settings before they reach production.


# Run the MSBuild analysis locally

dotnet run --project plugins/dotnet-msbuild/agents/msbuild.agent.csproj \
    --path MySolution.sln \
    --output msbuild-report.json

The agent outputs a JSON report identifying insecure property patterns, allowing teams to remediate issues before merging build file changes.

NuGet Vulnerability Detection

Before converting projects to Central Package Management (CPM), the skill defined in plugins/dotnet-nuget/skills/convert-to-cpm/references/audit-complexities.md validates package references against known security advisories. This prevents the consolidation of vulnerable dependencies into a centralized format.

var audit = await DotnetNuGetAudit.CheckAsync(
    solutionPath: "MySolution.sln",
    includeAdvisories: true);

if (audit.HasVulnerabilities)
{
    Console.WriteLine("Security advisories detected:");
    foreach (var adv in audit.Advisories)
        Console.WriteLine($"- {adv.Package} {adv.Version} : {adv.Cve}");
}

This check surfaces CVE information from NuGet’s advisory database, blocking CPM conversion until vulnerable packages are updated.

Secure Migration Patterns

Migration skills include security checklists for specific framework transitions. The plugins/dotnet-upgrade/skills/migrate-dotnet9-to-dotnet10/references/aspnet-core-dotnet9to10.md document requires verification that exception handlers continue emitting telemetry for authentication failures after upgrades. Similarly, plugins/dotnet-upgrade/skills/migrate-dotnet8-to-dotnet9/references/serialization-networking-dotnet8to9.md mandates redaction of query strings in HttpClient diagnostic events to prevent credential leakage in logs.

For native binary compilation, plugins/dotnet-upgrade/skills/migrate-dotnet8-to-dotnet9/references/containers-interop-dotnet8to9.md enforces enabling Control-flow Enforcement Technology (CET) to mitigate return-oriented programming attacks.

Security Test Tagging

The testing framework defined in plugins/dotnet-test/skills/test-tagging/SKILL.md introduces a security trait that must be applied to tests verifying authentication, authorization, and injection protections. This ensures security-critical logic maintains test coverage across refactors.

Runtime and Container Hardening

Containerized diagnostics in dotnet/skills enforce strict isolation boundaries. The documentation in plugins/dotnet-diag/skills/dump-collect/references/container-dumps.md requires specifying appropriate securityContext entries when running dump or trace collection containers. It explicitly warns that disabling AppArmor or SELinux protections should be limited strictly to debugging scenarios and never used in production environments.

Summary

  • Report vulnerabilities privately through the MSRC channel per SECURITY.md and CONTRIBUTING.md, never via public GitHub issues.
  • Automate PR scanning using the pr-malicious-scan.agent workflow to flag suspicious diffs with the pr-needs-security-review label.
  • Enforce minimal CI permissions by restricting workflow capabilities and whitelisting only necessary scripting languages.
  • Validate build files with the msbuild.agent to catch insecure MSBuild properties before merging.
  • Audit NuGet packages for known CVEs before executing CPM conversion through the audit-complexities.md skill.
  • Tag security tests with the security trait to maintain coverage for auth and injection checks.
  • Harden containers by maintaining securityContext constraints and avoiding privileged debugging modes in production.

Frequently Asked Questions

How do I report a security vulnerability in dotnet/skills?

You must submit vulnerability reports privately through the Microsoft Security Response Center (MSRC) as specified in SECURITY.md. Public GitHub issues are explicitly prohibited for security-sensitive disclosures to prevent exploit exposure before patches are available.

What triggers the pr-needs-security-review label?

The .github/workflows/pr-malicious-scan.agent.md workflow automatically applies this label when its diff-scanning logic detects known security patterns, such as credential injections, suspicious script embeddings, or unauthorized API access attempts in the proposed changes.

How does dotnet/skills handle security in generated migration code?

Migration skills embed security checklists that validate exception handlers emit telemetry for authentication failures, enforce query string redaction in HttpClient events per serialization-networking-dotnet8to9.md, and require CET enablement for native binaries as documented in containers-interop-dotnet8to9.md.

Are there automated checks for vulnerable NuGet packages?

Yes. The convert-to-cpm skill references audit-complexities.md to detect and surface known security advisories from NuGet before converting projects to Central Package Management, ensuring vulnerable packages are not consolidated into the centralized package graph.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →