.NET Azure Identity Review (secretless, managed identity)

    1

    It works on the laptop and becomes a rotation incident in production.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    .NET Azure Identity Review (secretless, managed identity)

    Example session with this skill installed

    Scan this repo for Azure keys, SAS strings, SQL passwords and client secrets, then move it to DefaultAzureCredential with the right RBAC roles. Don't print any secret values.

    • Read your context and instructions
    • Compiled the net azure identity

    Scan (real scanner output on a seeded test fixture)

    bad/Program.cs:2: AZID007 SDK client built from a connection string (construct with endpoint/namespace Uri + TokenCredential)
        var blobs = new BlobServiceClient(builder.Configuration.GetConnectionString("Storage"));
    bad/Program.cs:3: AZID007 SDK client built from a connection string (construct with endpoint/namespace Uri + TokenCredential)
        var bus = new ServiceBusClient(sbConnectionString);
    bad/Program.cs:4: AZID004 ClientSecretCredential in code (prefer managed identity / workload identity federation)
        var cred = new ClientSecretCredential(tenant, clientId, secret);
    bad/Program.cs:5: AZID006 SAS token signature literal (sig=) in source/config (issue short-lived user-delegation SAS at runtime)
        const string Sas = "https://acct.blob.core.windows.net/c/f.txt?sv=2024-08-04&sr=b&sig=AbC***3D";
    bad/appsettings.json:3: AZID001 storage/Cosmos account key in a connection string or literal (use DefaultAzureCredential + RBAC)
        "Storage": "DefaultEndpointsProtocol=https;AccountName=acct;AccountKey=Zm9***==;EndpointSuffix=core.windows.net",
    bad/appsettings.json:4: AZID002 Service Bus / Event Hubs SAS key in a connection string (use fully-qualified namespace + TokenCredential)
        "Bus": "Endpoint=sb://ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Zm9***==",
    bad/appsettings.json:5: AZID003 SQL password in a connection string (use Authentication=Active Directory Default + managed identity)
        "Sql": "Server=tcp:x.database.windows.net;Database=d;User ID=app;Password=Sup***!x;"
    bad/appsettings.json:7: AZID005 client secret value in config (remove; use managed identity, or Key Vault reference if a secret is unavoidable)
        "AzureAd": { "ClientSecret": "abc***23" }
    
    8 finding(s).
    

    Secret values are masked by the scanner (Zm9***==), so they never land in the agent transcript.

    What the agent does next

    FindingChangeRBAC role (scope)
    AZID001 / AZID007 Blobaz.AddBlobServiceClient(new Uri(cfg["Storage:BlobEndpoint"])) + az.UseCredential(new DefaultAzureCredential())Storage Blob Data Contributor (storage account)
    AZID002 / AZID007 Service Busaz.AddServiceBusClientWithNamespace("ns.servicebus.windows.net")Azure Service Bus Data Sender / Receiver (namespace)
    AZID003 SQLAuthentication=Active Directory Default;, drop User ID/Password; CREATE USER [app] FROM EXTERNAL PROVIDERdb_datareader / db_datawriter
    AZID004 / AZID005Remove ClientSecretCredential and AzureAd:ClientSecret; managed identity in Azure, OIDC federation in CIn/a
    AZID006Issue a 15-minute user-delegation SAS at runtimeStorage Blob Delegator + data role

    Verify

    • Re-run scanner: expect 0 finding(s)., exit 0
    • dotnet build and dotnet test

    Rotate now: the storage key, Service Bus SAS key, SQL password and client secret were committed; removing them from the repo does not revoke them.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    AI agents copy Azure quick-starts: storage strings with AccountKey=, Service Bus strings with SharedAccessKey=, Password= in the SQL string, and ClientSecretCredential with the secret in appsettings.json. It works on the laptop and becomes a rotation incident in production.

    This skill gives your agent the rules an Azure-experienced .NET reviewer applies, plus a stdlib-only Python scanner that flags 7 issues (AZID001-007) across .cs, json, Bicep and pipeline YAML before the agent changes anything.

    What it does

    • Scan, then rewrite clients to endpoint + TokenCredential (AddAzureClients + DefaultAzureCredential), name the least-privilege data-plane role, then verify (re-scan, dotnet build, dotnet test)
    • Per-service before/after: Blob, Queue, Service Bus, Event Hubs, Cosmos DB, Azure SQL (Active Directory Default), Key Vault, user-delegation SAS
    • Output: file:line, rule, before/after, RBAC role + scope, and a "rotate now" flag for committed secrets

    Rules flagged

    CodeFinding
    AZID001Storage/Cosmos AccountKey=
    AZID002Service Bus/Event Hubs SharedAccessKey=
    AZID003SQL Password= (skipped when Active Directory auth is used)
    AZID004ClientSecretCredential in code
    AZID005Client secret value in config
    AZID006SAS sig= literal
    AZID007SDK client constructed from a connection string

    Targets .NET 8+ with Azure.* SDKs (written for .NET 10). The scanner is heuristic, line-based and read-only: it writes nothing, makes no network calls, skips placeholders like <your-key> / ${VAR} / __TOKEN__, and masks secret values in its output. It does not prove an identity has the right role. MIT licensed.

    Scanner is line-based and heuristic. Skips placeholders and environment variables. Does not verify if the target identity has the actual RBAC roles assigned in Azure.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 day ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell
    Read Files
    Listed1 day ago

    What's inside

    Frequently Asked Questions

    It gives your agent review rules plus a read-only scanner. The agent finds keys, SAS strings, SQL passwords and client secrets, then rewrites the clients to use an endpoint URI with DefaultAzureCredential and tells you which RBAC role each identity needs. You review and apply the changes; nothing is changed in Azure.

    Rules are written for .NET 10 and apply to .NET 8+ with the Azure.* SDKs. Reference material covers Blob, Queue, Service Bus, Event Hubs, Cosmos DB, Azure SQL, Key Vault and user-delegation SAS.

    No. It names the data-plane role and scope (for example Storage Blob Data Contributor on the storage account) and includes a Bicep sketch. Assigning roles is up to you or your pipeline.

    It is line-based and heuristic. It misses secrets built across multiple lines, injected by pipelines, or held in environment variables and user-secrets, and it skips obvious placeholders. Treat a clean scan as a prompt for review, not proof.

    SKILL.md with the workflow and rules, two reference files (per-service before/after code; RBAC roles and the local-dev loop), a stdlib-only Python scanner (AZID001-007) and the MIT license. It is free.

    No. It reads files, writes nothing, makes no network calls and masks matched secret values in its output. Any secret it finds in a committed file should still be rotated.

    New in DevOps & Cloud