[BUG]: Some JS characters aren't escaped when running the page-ready check
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, python
- Lĩnh vực
- devtools, security, testing-qa
Hướng nghiên cứu
Lỗi nằm trong src/choreographer/protocol/devtools_async_helpers.py tại dòng 37, nơi một URL được chèn vào một template literal JavaScript. Hãy bắt đầu bằng cách kiểm tra hàm create_and_wait và các trình trợ giúp giao thức devtools xung quanh. Sử dụng json.dumps để escape chuỗi URL một cách chính xác, và cũng cập nhật hàm để kiểm tra exceptionDetails trong phản hồi. Chạy tập lệnh tái tạo được cung cấp để xác minh bản sửa lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
The page-ready check inserts the URL into a JavaScript template literal without escaping it, at src/choreographer/protocol/devtools_async_helpers.py:37. A backtick in the URL ends the literal, and a ${...} sequence in the URL runs as JavaScript.
Steps to reproduce
- Run the following code:
import asyncio
import choreographer as choreo
from choreographer.protocol.devtools_async_helpers import create_and_wait
async def main():
browser = await choreo.Browser(headless=True)
try:
# Correct: raises TimeoutError after 5s, because the address never loads
await create_and_wait(browser, url="http://192.0.2.1:9999", timeout=5.0)
except TimeoutError:
print("plain URL: TimeoutError")
# Wrong: returns after 0.02s, for the same unreachable address
await create_and_wait(browser, url="http://192.0.2.1:9999/`", timeout=5.0)
print("URL with a backtick: returned OK")
await browser.close()
asyncio.run(main())
For the second problem, pass https://www.example.com/${(window.__injected = 42, "")} to create_and_wait, then read window.__injected back from the page. The value is 42.
Notes
- With this bug:
- A backtick makes the script raise a
SyntaxError.Runtime.evaluatereturns that as a normal response, and the race increate_and_waitcounts any finished task as a load. Socreate_and_waitreturns a tab for a page that never loaded. - A
${...}sequence runs arbitrary JavaScript in the page.
- A backtick makes the script raise a
- A fix is to build the JavaScript string with
json.dumps(url)and drop the backticks from the template.json.dumpssupplies its own quotes and escapes the contents, so a backtick and a${are both inert. create_and_waitshould also inspect the response forexceptionDetailsinstead of counting every finished task as a successful load- This was found while working on #295
- Ngôn ngữ chính
- Python
- Star
- 17
- Fork
- 10
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của plotly/choreographer
-
Multiple choreographer errors in docker and apptainer when trying to export figure with plotlyĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
plotly/choreographer#287 · 7 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
plotly/choreographer#284 ·
-
Can close logger-pipe fasterĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
plotly/choreographer#259 ·
Tất cả issue của plotly/choreographer
Issue tương tự
-
bump patch
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
autowarefoundation/autoware_carla_scenario#1321 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
QuantConnect/Documentation#2838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
get_all_subclasses must deduplicate by class identityCó thể đã có người làm @Gambit-Checkmate đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 15 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 bình luận ·