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
|
|
@ -63,6 +63,10 @@ export const KEEP_MAX_BYTES = 10 * MB;
|
|||
|
||||
/* Longest side after processing, in pixels. Wide enough for a
|
||||
full-bleed hero on a large screen. */
|
||||
// About 60 megapixels (eg. 9000 x 6700): past any camera an editor
|
||||
// uses, and it stops one giant image eating the VPS's memory while
|
||||
// it's decoded. sharp's own default is 268 MP.
|
||||
const MAX_INPUT_PIXELS = 60_000_000;
|
||||
const MAX_EDGE = 2400;
|
||||
|
||||
const WEBP_QUALITY = 82;
|
||||
|
|
@ -141,7 +145,7 @@ export async function store(buf, { keepOriginal = false } = {}) {
|
|||
try {
|
||||
if (convert) {
|
||||
// animated keeps every frame of a GIF or an animated WebP.
|
||||
const { data, info } = await sharp(buf, { animated: true })
|
||||
const { data, info } = await sharp(buf, { animated: true, limitInputPixels: MAX_INPUT_PIXELS })
|
||||
.rotate()
|
||||
.resize({ width: MAX_EDGE, height: MAX_EDGE, fit: "inside", withoutEnlargement: true })
|
||||
.webp({ quality: WEBP_QUALITY })
|
||||
|
|
@ -152,7 +156,7 @@ export async function store(buf, { keepOriginal = false } = {}) {
|
|||
// An animated image reports the whole strip's height.
|
||||
height = info.pageHeight ?? info.height;
|
||||
} else if (kind !== "svg") {
|
||||
const meta = await sharp(buf).metadata();
|
||||
const meta = await sharp(buf, { limitInputPixels: MAX_INPUT_PIXELS }).metadata();
|
||||
width = meta.width ?? null;
|
||||
height = meta.pageHeight ?? meta.height ?? null;
|
||||
}
|
||||
|
|
@ -209,7 +213,7 @@ async function describe(filename) {
|
|||
let height = null;
|
||||
if (kind !== "svg") {
|
||||
try {
|
||||
const meta = await sharp(buf).metadata();
|
||||
const meta = await sharp(buf, { limitInputPixels: MAX_INPUT_PIXELS }).metadata();
|
||||
width = meta.width ?? null;
|
||||
height = meta.pageHeight ?? meta.height ?? null;
|
||||
} catch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue