Insertion of Sensitive Information Into Sent Data
The product sends data to another actor, but this data contains sensitive information that should not be accessible to that actor.
An attacker may be able to intercept or receive data that contains sensitive information, such as credentials, tokens, or internal system details, that were not intended for them.
この脆弱性の修正方法
3 件の Shoulder 検出ルールに基づく Insertion of Sensitive Information の予防策。
Validate webhook URLs against an allowlist and never send internal credentials to user-controlled endpoints
- func webhook(w http.ResponseWriter, r *http.Request) { - endpoint := r.FormValue("webhook_url") - req, _ := http.NewRequest("POST", endpoint, nil) - req.Header.Set("X-API-Key", os.Getenv("INTERNAL_API_KEY")) + var allowedDomains = map[string]bool{ + "api.slack.com": true, + "hooks.stripe.com": true, + } + + func webhook(w http.ResponseWriter, r *http.Request) { + endpoint := r.FormValue("webhook_url") + parsed, err := url.Parse(endpoint) + if err != nil || !allowedDomains[parsed.Host] { + http.Error(w, "Untrusted domain", 400) + return + } + req, _ := http.NewRequest("POST", endpoint, body) + req.Header.Set("X-Webhook-Secret", userWebhookSecret) client := &http.Client{} client.Do(req) }
Validate webhook URLs against a domain allowlist and never send internal credentials
- app.post('/webhook/register', async (req, res) => { - await fetch(req.body.webhookUrl, { - headers: { 'Authorization': `Bearer ${process.env.API_KEY}` } + const ALLOWED_DOMAINS = ['api.slack.com', 'hooks.stripe.com']; + + app.post('/webhook/register', async (req, res) => { + const url = new URL(req.body.webhookUrl); + if (!ALLOWED_DOMAINS.includes(url.hostname)) { + return res.status(400).json({ error: 'Untrusted domain' }); + } + await fetch(url, { + headers: { 'X-Webhook-Secret': req.body.webhookSecret } }); });
コードの脆弱性を見つける
Shoulderを使用してコードのInsertion of Sensitive Information Into Sent Dataパターンをスキャンしましょう。 3 ルール.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=201 # Or scan entire project npx @shoulderdev/cli trust .
検出ルール (3)
コードレビューで注目すべき点
これらのパターンはInsertion of Sensitive Information Into Sent Dataの潜在的な脆弱性を示しています。コードレビューとセキュリティ監査中に探してください。
コードベースをスキャン: Insertion of Sensitive Information Into Sent Data
Shoulder CLI はコードベース全体から脆弱なパターンを見つけます。