Back to skill

Security audit

.net-full-stack-architect

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent .NET architecture guide, but its security-sensitive JWT and logging templates include copyable patterns that could weaken authorization and expose request data.

Install only if you are comfortable reviewing generated security code before use. Pay special attention to JWT permission issuance, resource-owner checks, policy names, and request logging; replace hard-coded permission claims with permissions loaded from your authorization store, and do not log full request bodies or tokens in production.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
references/auth-jwt.md:69
Finding

Unconditional JWT Permission Claims Allow Privilege Escalation

Content
View full analysis

Vulnerability Details

File Location: references/auth-jwt.md, lines 69–80; authorization use at lines 106–128
Vulnerability Type: Improper authorization and excessive privilege assignment
Risk Level: High

Vulnerable Code

csharp
public (string access, string refresh) Generate(User user)
{
    var claims = new[]
    {
        new Claim(JwtRegisteredClaimNames.Sub, user.Id.ToString()),
        new Claim(JwtRegisteredClaimNames.Name, user.UserName),
        new Claim("tenant", user.TenantId),
        new Claim(ClaimTypes.Role, user.Role),
        // Permission claims used during authorization
        new Claim("permission", "order.read"),
        new Claim("permission", "order.write"),
        new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
    };

The claims are subsequently trusted by authorization policies and protected endpoints:

csharp
services.AddAuthorization(options =>
{
    // Role policy
    options.AddPolicy("AdminOnly", p => p.RequireRole("Admin"));

    // Permission policies
    options.AddPolicy("OrderRead",
        p => p.RequireClaim("permission", "order.read"));
    options.AddPolicy("OrderWrite",
        p => p.RequireClaim("permission", "order.write"));
});

[Authorize(Policy = "OrderRead")]
[HttpGet("{id}")]
public async Task<IActionResult> Get(long id) { ... }

Technical Analysis

The token-generation template unconditionally assigns both order.read and order.write claims to every user passed to Generate. It does not retrieve or validate the user's actual permissions from a trusted authorization store.

The documented authorization policies then treat possession of these claims as sufficient evidence of authorization. Consequently, authentication implicitly grants order read and write privileges, defeating the intended distinction between ordinary authenticated users and users authorized for those op ...[truncated 1605 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove all unconditional permission claims from the token-generation method.
  • Resolve the authenticated user's effective permissions from a trusted server-side role or permission store.
  • Scope permission resolution to the authenticated user and current tenant.
  • Issue only permissions explicitly assigned to that principal, following deny-by-default and least-privilege principles.
  • Validate that the user is active and that permission assignments have not been revoked before issuing or refreshing a token.
  • Consider a permission-version or security-stamp claim so permission changes can invalidate previously issued tokens.
  • Ensure refresh-token processing re-evaluates current permissions rather than copying stale authorization state.
  • Add negative authorization tests demonstrating that a user without order.write neither receives that claim nor accesses endpoints protected by the OrderWrite policy.
  • Independently enforce tenant and resource ownership constraints at the data-access or resource-authorization layer.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (9)

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · references/auth-jwt.md (reported line 176)May include surrounding context.

md
[HttpPost("refresh")]
public async Task<IActionResult> Refresh([FromBody] RefreshRequest req)
{
    // 1. 校验 access token 签名(允许已过期)
    var principal = _tokenService.ValidateExpiredToken(req.AccessToken);
    // 2. 比对 Redis 中 refresh token(不存在/不匹配 → 401,可能是重放攻击)
    var stored = await _cache.GetAsync($"rt:{principal.GetUserId()}");

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file is natural-language documentation, and its instructions and explanations are entirely in Chinese. The policy requires flagging language or locale constraints when the skill forces a specific language without user opt-in, and the file does not offer alternatives or explain that it is intentionally region-specific.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The JWT issuance example puts the user identifier in the sub claim, but the resource-authorization handler reads ClaimTypes.NameIdentifier. In ASP.NET Core, this mismatch can cause ownership checks to fail or behave unexpectedly, leading developers to weaken authorization logic or incorrectly deny/allow access depending on claim mapping configuration.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The sample decorates the endpoint with [Authorize(Policy = nameof(OrderOwnerRequirement))] but then performs an imperative check against OrderOwnerPolicy. This inconsistency can leave the declarative policy ineffective, confuse maintainers, and create gaps where intended authorization is not actually enforced uniformly across endpoints.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The request-logging example pushes RequestBody from httpContext.Items into Serilog diagnostic context, which can cause full request payloads to be written to logs. This conflicts with the later guidance explicitly forbidding full request/response bodies and JWT logging, and can expose credentials, tokens, PII, or business-sensitive data in centralized log storage.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The example records request body data without any adjacent privacy or sensitivity warning, making unsafe logging patterns easy for developers to copy into production. In a .NET Web API architecture skill, such examples are likely to be reused directly, increasing the chance of accidental leakage of passwords, JWTs, personal data, or regulated content.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown reference is written entirely in Chinese and presents itself as a general skill reference file, but it does not state that the skill is region-specific or offer an opt-in language choice. Under the policy, forcing a specific language without user opt-in is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The title and surrounding guidance are entirely written in Chinese, which signals a language-specific requirement for using this skill reference. The file does not offer an alternative language, user opt-in, or a documented justification that the skill is intentionally region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file contains all instructional content in Chinese and does not indicate that the user can choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the language/locale policy rule, forcing a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.