Security hardening: rate limiting, atomic locks, origin check, honest docs
API / Security: - Add api/_helpers.php: shared send_security_headers(), verify_origin(), get_hmac_secret(), check_rate_limit(), read_json_locked(), write_json_locked() - shorten.php: remove Access-Control-Allow-Origin:*, restrict to same-origin, rate-limit 20 req/h per IP, atomic JSON read+lock, HMAC secret from file - verify.php: rate-limit GET (30/min) and POST (10/h) per IP, atomic lock, prevent overwriting existing proofs, origin check on POST - node.php: fix rate limit from 1000 to 60 req/min, add security headers, origin check - check-short.php: add security headers, re-derive signature server-side - s.php: use file-based HMAC secret via get_hmac_secret(), hash_equals() for timing-safe comparison Service Worker: - sw.js: navigation requests (mode=navigate) never served from cache; network-first with offline fallback to prevent stale invoice state Documentation (honest claims): - README: tagline "No backend" -> "No tracking"; new Architecture table listing exactly what server sees for each feature; Security Model section - index.html: meta description and footer updated from "No Backend" to "Minimal Backend" - i18n.js footer: already updated in previous commit
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/_helpers.php';
|
||||
|
||||
/**
|
||||
* Monero Daemon RPC Proxy
|
||||
* Forwards allowed RPC requests to Monero nodes, bypassing CORS.
|
||||
@@ -6,6 +8,8 @@
|
||||
*/
|
||||
|
||||
header('Content-Type: application/json');
|
||||
send_security_headers();
|
||||
verify_origin();
|
||||
|
||||
// Only POST
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
@@ -41,7 +45,7 @@ if (file_exists($rateFile)) {
|
||||
$rateData = array_filter($rateData, fn($t) => $t > $now - 60);
|
||||
}
|
||||
|
||||
if (count($rateData) >= 1000) {
|
||||
if (count($rateData) >= 60) {
|
||||
http_response_code(429);
|
||||
echo json_encode(['error' => 'Rate limit exceeded']);
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user