diff --git a/api/internal/httpapi/security.go b/api/internal/httpapi/security.go new file mode 100644 index 0000000..d369082 --- /dev/null +++ b/api/internal/httpapi/security.go @@ -0,0 +1,74 @@ +package httpapi + +import ( + "net/http" + "net/url" + "strings" +) + +// Browser-driven cross-site attacks are the realistic threat here. The +// dashboard is reached with a browser session, so any page the operator +// happens to visit can make their browser issue requests to the pool +// with whatever credentials that session carries. Two shapes matter: +// +// - Cross-Site WebSocket Hijacking. The WebSocket handshake is not +// subject to the same-origin policy, so without a check any site +// could open /api/ws and read the whole snapshot: payout addresses, +// per-worker hashrates, block history. +// - CSRF against the state-changing POSTs. The admin endpoints take no +// body, so a plain