Fix the Panel account bug and harden what the second audit found
- Panel: changing a role or disabling an account always failed (db.transaction doesn't exist on node:sqlite); it uses tx() now - Feeds and link previews are scanned with indexOf, not whole-document regexes, so a hostile feed or page can't freeze the server; entity decoding can't throw; escaped-HTML descriptions make clean excerpts - Feed reads share one fetch per feed and serve the stale copy while a refresh runs - Deliberate HTTP errors (the CSRF 403) keep their status instead of becoming logged 500s; a JSON null body is handled - url columns read the scheme the way the URL parser does, so control characters can't hide javascript: - Google sign-in state cookie is __Host- and its return page is checked again; more reserved ranges blocked for previews and feeds, and a 15 s cap on each whole fetch - Log lines from visitor text are made single-line and short; list limits can't go negative; entity names can't hit object prototypes - A clip title can't point the clip tool at another file - Uploads over 60 MP are refused before decoding; the Keep original help says a photo's location stays in it - admin-cli add defaults to the editor role Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fd40907ed6
commit
be7e92417e
18 changed files with 226 additions and 59 deletions
|
|
@ -113,7 +113,9 @@ function coerceValue(column, raw, errors, prefix = "") {
|
|||
}
|
||||
case "url": {
|
||||
const value = String(raw).trim();
|
||||
const scheme = URL_SCHEME.exec(value)?.[1].toLowerCase();
|
||||
// The URL parser ignores control characters, spaces and tabs
|
||||
// inside a scheme ("java\tscript:"), so read it the same way.
|
||||
const scheme = URL_SCHEME.exec(value.replace(/[\u0000-\u0020\u007f]/g, ""))?.[1].toLowerCase();
|
||||
if (scheme && !SAFE_SCHEMES.has(scheme)) {
|
||||
errors[key] = "Links must start with http://, https://, mailto: or tel:, or be a site path like /retreats.";
|
||||
return null;
|
||||
|
|
@ -160,7 +162,7 @@ export function listRows(db, entity, query = {}) {
|
|||
params.push(...search.map(() => term));
|
||||
}
|
||||
|
||||
const limit = Math.min(Number(query.limit) || 200, 500);
|
||||
const limit = Math.max(1, Math.min(Number(query.limit) || 200, 500));
|
||||
|
||||
const rows = db
|
||||
.prepare(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue