ベータ Shoulder はベータ版です — 結果が誤っている場合があります。皆さまのフィードバックが次に修正する内容を決定します。 フィードバックを送る
🔤

Improper Handling of Unicode Encoding

🛡️ 3 件のルールが検出します

Improper Handling of Unicode Encoding

The product does not properly handle when an input contains Unicode encoding.

Unicode characters can have multiple encodings or representations. If an application does not properly handle Unicode, attackers may be able to bypass security filters or cause unexpected behavior using alternate encodings.

普及度
3 言語をカバー
影響度
ミディアム
レビュー推奨
予防
文書化済み
3 件の修正例
2 予防
2 予防

この脆弱性の修正方法

3 件の Shoulder 検出ルールに基づく Improper Handling of Unicode の予防策。

Unicode Normalization Security Issues MEDIUM

Normalize strings with NFKC before security-sensitive comparisons

+6 -3 go
- func handler(w http.ResponseWriter, r *http.Request) {
-     username := r.FormValue("username")
-     if username == "admin" {
+ import "golang.org/x/text/unicode/norm"
+ 
+ func handler(w http.ResponseWriter, r *http.Request) {
+     username := r.FormValue("username")
+     normalized := norm.NFKC.String(strings.ToLower(username))
+     if normalized == "admin" {
          grantAdminAccess()
      }
  }
  
Unicode Normalization Security Issues MEDIUM

Normalize Unicode strings with NFKC before security-sensitive comparisons

+2 -1 javascript
  app.post('/login', (req, res) => {
-   if (req.body.username === 'admin') {
+   const username = req.body.username.normalize('NFKC').toLowerCase();
+   if (username === 'admin') {
      return res.send('Admin access');
    }
  });
  
Unicode Normalization Issues MEDIUM

Normalize Unicode strings with NFKC before comparison or security-critical operations

+6 -2 python
- def check_username(input_name, stored_name):
-     if input_name == stored_name:
+ import unicodedata
+ 
+ def check_username(input_name, stored_name):
+     normalized_input = unicodedata.normalize('NFKC', input_name).lower()
+     normalized_stored = unicodedata.normalize('NFKC', stored_name).lower()
+     if normalized_input == normalized_stored:
          grant_access()
  
3 検出
3 検出

コードの脆弱性を見つける

Shoulderを使用してコードのImproper Handling of Unicode Encodingパターンをスキャンしましょう。 3 ルール.

ターミナル
# Scan with Shoulder CLI
npx @shoulderdev/cli trust --cwe=176

# Or scan entire project
npx @shoulderdev/cli trust .
4 警告サイン
4 警告サイン

コードレビューで注目すべき点

これらのパターンはImproper Handling of Unicode Encodingの潜在的な脆弱性を示しています。コードレビューとセキュリティ監査中に探してください。

🟡
missing Unicode normalization in security-sensitive string comparisons javascript-unicode-normalization
🔍

コードベースをスキャン: Improper Handling of Unicode Encoding

Shoulder CLI はコードベース全体から脆弱なパターンを見つけます。