github / github/codeql

[JavaScript] - Incomplete string escaping or encoding

Đang mở
#9,450 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
JS question
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**Description of the issue**

File: [[javascript/ql/src/Security/CWE-116/IncompleteSanitization.ql](https://github.com/github/codeql/blob/90bebaa5a9a34265ccdf25d3003eaf0f23d2f1a7/javascript/ql/src/Security/CWE-116/IncompleteSanitization.ql)]
Description: A string transformer that does not replace or escape all occurrences of a meta-character may be ineffective.

Usage: "WorkflowId": workflowId.replace("}", "")

Issue: This replaces only the first occurrence of "}", but not all the occurrences.

workflowId is a system generated GUID and contains single occurrence of "{" & "}"

Sample Input & Output:
Input: {9ca385f1-88d7-ec11-a7b5-002248283310}
Output: 9ca385f1-88d7-ec11-a7b5-002248283310

In our scenario, we are using replace() function to replace only first occurrence of a character in a system generated GUID (not user input). As per the exception, it is suggested to use '/g' or regular expression to fix all the occurrences of any replacement character. But replacement of all the occurrences is not valid in our scenario.

Is this a valid rule that should be applied to any scenario (like ours)? or applicable only for few scenarios like for sanitizing user inputs or for rendering the data etc.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.