SIGN IN SIGN UP
NaiboWang / EasySpider UNCLAIMED

A visual no-code/code-free web crawler/spider易采集:一个可视化浏览器自动化测试/数据采集/爬虫软件,可以无代码图形化的设计和执行爬虫任务。别名:ServiceWrapper面向Web应用的智能化服务封装系统。

0 0 56 JavaScript

fix(server): restrict CORS and bind local API to loopback (CWE-352)

The local Electron HTTP server (server.js) exposes endpoints that spawn
child processes (/executeTask), read/write task and config files
(/manageTask, /setUserDataFolder, /deleteTask), and otherwise perform
state-changing actions, but it has no authentication and previously sent
'Access-Control-Allow-Origin: *' on every response.

Because the server listens on a predictable local port, any website the
user visited could issue cross-origin POSTs to drive task creation and
execution (CWE-352 / CSRF).

This change:
- Removes the unconditional ACAO:* header.
- Echoes Access-Control-Allow-Origin only for loopback origins
  (http(s)://localhost, 127.0.0.1, [::1]).
- Rejects requests with a non-local Origin header with HTTP 403.
- Handles CORS preflight (OPTIONS) safely.
- Binds the HTTP server (port 8074) and Express upload server
  (port 8075) to 127.0.0.1 only, so they are not exposed on the LAN.
- Restricts the express 'cors' middleware to the same loopback allowlist.
S
Sebastion committed
38e63282e884d3a38b084e8b480dcbcf481eb9ad
Parent: 1984f0d