Missing "Cross-window communication with unrestricted target origin" because of wrapping by (javascript) blockstatement
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 152
Mô tả
Hi,
I am using CodeQL 2.20.6, there is the code:
```js
// {
const t = {};
const r = localStorage.getItem("pw_uuid");
r && JSON.parse(r).data && (t.uuid = JSON.parse(r).data);
window.parent.postMessage(JSON.stringify({
type: "_pwUserDataReady",
key: "",
data: t
}), "*");
// }
```
Where CodeQL should give me a "Cross-window communication with unrestricted target origin" alert but it doesn't.
If I remove the first and last line comments, i.e., wrapping by a block as the code is:
```js
{
const t = {};
const r = localStorage.getItem("pw_uuid");
r && JSON.parse(r).data && (t.uuid = JSON.parse(r).data);
window.parent.postMessage(JSON.stringify({
type: "_pwUserDataReady",
key: "",
data: t
}), "*");
}
```
It does give me one:
```csv
"Cross-window communication with unrestricted target origin", "When sending sensitive information to another window using `postMessage`, the origin of the target window should be restricted to avoid unintentional information leaks.", "error","[[""Sensitive data""|""relative:///iframe.js:3:15:3:45""]] is sent to another window without origin restriction.","/iframe.js", "5", "31", "9", "6"
```
This issue looks the same with but it should be fixed in 2.20.6, shouldn't it?
Hướng dẫn đóng góp
Hướng nghiên cứu
Tái hiện báo cáo trong CodeQL 2.20.6 bằng hai biến thể JavaScript, có và không có block wrapper, rồi so sánh các kết quả tại các vị trí /iframe.js được báo cáo. Đọc issue liên quan #18652 để biết ngữ cảnh. Công việc được coi là hoàn tất khi postMessage không bị hạn chế được báo cáo ở cả hai dạng, hoặc giới hạn được hỗ trợ được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- security
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100