# Exposure of Sensitive Information to an Unauthorized Actor (CWE-200) The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. **Stack:** Go - Prevalence: 高 频繁被利用 - Impact: 关键 4 条严重级别为关键的规则 - Prevention: 已记录 14 个修复示例 **OWASP:** Broken Access Control (A01:2021-Broken Access Control) - #1 ## Description There are many different kinds of mistakes that introduce information exposures. The severity of the error can range widely, depending on the context in which the product operates, the type of sensitive information that is revealed, and the benefits it may provide to an attacker. ## Prevention 基于 4 条 Shoulder 检测规则的 Information Exposure 预防策略。 ### Go Use environment variables for configuration only; never log or return their values Store API keys in environment variables, never log them, and protect model endpoints with authentication Mask PII and redact credentials before sending data to LLM APIs, and use structured logging ## Warning Signs - [HIGH] Model theft vulnerability: ... - [HIGH] vulnerabilities leading to model theft or API key exposure such as hardcoded keys or insecure model - [HIGH] Potential sensitive information disclosure: ... - [HIGH] sensitive information disclosure in AI/LLM implementations such as credentials or PII in prompts ## Consequences - 读取应用程序数据 - 读取文件或目录 ## Mitigations - 对系统进行分隔,使信任边界可以明确划分的安全区域得以存在 - 确保错误信息只包含对目标受众有用的最少细节 ## Detection - Total rules: 14 - Critical: 4 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (4 rules) - **Environment Variable Secret Exposure** [HIGH]: Environment variables containing secrets flow to logs or HTTP responses. - Remediation: Use environment variables for configuration only, never log or return them. ```go apiKey := os.Getenv("API_KEY") if apiKey == "" { log.Fatal("API_KEY not configured") } // Use apiKey internally, never log or return it ``` Learn more: https://shoulder.dev/learn/go/cwe-200/env-vars-secret-exposure - **LLM Model Theft** [HIGH]: Detects vulnerabilities leading to model theft or API key exposure such as hardcoded keys or insecure model endpoints. - Remediation: Use environment variables for API keys and authenticate model endpoints. ```go client := openai.NewClient(os.Getenv("OPENAI_API_KEY")) ``` Learn more: https://shoulder.dev/learn/go/cwe-200/llm-model-theft - **LLM Sensitive Information Disclosure** [HIGH]: Detects sensitive information disclosure in AI/LLM implementations such as credentials or PII in prompts. - Remediation: Mask or redact PII and credentials before sending to LLM APIs. ```go safeMessage := maskPII(userInput) safeMessage = redactCredentials(safeMessage) ``` Learn more: https://shoulder.dev/learn/go/cwe-200/llm-sensitive-info-disclosure - **Sensitive Field Exposure in API Response** [CRITICAL]: Sensitive fields like password, token, or apiKey included in HTTP responses. - Remediation: Use response DTOs or json:"-" tag to exclude sensitive fields. ```go type User struct { ID string `json:"id"` Email string `json:"email"` Password string `json:"-"` // Never serialized } ``` Learn more: https://shoulder.dev/learn/go/cwe-200/sensitive-field-response-exposure