{"record":{"id":"7492feb36df3ee56","repo":"joewalnes/websocketd","slug":"maxframesize-must-not-be-negative-use-0-for-unl","errorCode":null,"errorMessage":"--maxframesize must not be negative; use 0 for unlimited","messagePattern":"--maxframesize must not be negative; use 0 for unlimited","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config.go","lineNumber":174,"sourceCode":"}\n\n// validateAnyOrigin checks that --anyorigin is not combined with an actual\n// origin policy. The flags say opposite things, and silently preferring one\n// would hide operator confusion.\nfunc validateAnyOrigin(anyOrigin, sameOrigin bool, allowOrigins []string) error {\n\tif anyOrigin && (sameOrigin || allowOrigins != nil) {\n\t\treturn fmt.Errorf(\"--anyorigin means 'accept any origin' and cannot be combined with --sameorigin or --origin, which restrict it\")\n\t}\n\treturn nil\n}\n\n// validateMaxFrameSize rejects negative --maxframesize values. The read\n// limit is only applied for positive values, so a negative value silently\n// meant \"unlimited\" — the one value an operator can pass that quietly\n// removes the DoS protection the flag exists for (issue #472).\nfunc validateMaxFrameSize(maxFrameSize int64) error {\n\tif maxFrameSize < 0 {\n\t\treturn fmt.Errorf(\"--maxframesize must not be negative; use 0 for unlimited\")\n\t}\n\treturn nil\n}\n\n// buildParentEnv constructs the filtered parent environment variable list.\nfunc buildParentEnv(passenv string) []string {\n\tenv := make([]string, 0)\n\tnewlineCleaner := strings.NewReplacer(\"\\n\", \" \", \"\\r\", \" \")\n\tfor _, key := range strings.Split(passenv, \",\") {\n\t\tif key == \"HTTPS\" {\n\t\t\tcontinue\n\t\t}\n\t\tif v := os.Getenv(key); v != \"\" {\n\t\t\tif clean := strings.TrimSpace(newlineCleaner.Replace(v)); clean != \"\" {\n\t\t\t\tenv = append(env, fmt.Sprintf(\"%s=%s\", key, clean))\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/joewalnes/websocketd/blob/7a8683dc7f9778dc615945aaed2a8dc77290227b/config.go#L156-L192","documentation":"validateMaxFrameSize rejects negative --maxframesize values. The WebSocket read limit is only applied for positive values, so a negative value silently meant 'unlimited' — quietly removing the DoS protection the flag exists for (issue #472).","triggerScenarios":"Running websocketd with --maxframesize=-1 (or any negative number). Previously this silently disabled the frame-size limit; now startup fails.","commonSituations":"Using -1 to mean 'unlimited' by convention from other tools; scripted defaults that substitute -1 when no size is configured.","solutions":["Use --maxframesize=0 for unlimited frames","Pass a positive byte value, e.g. --maxframesize=1048576 for 1 MiB","Fix scripts/templates that default the flag to -1"],"exampleFix":"// before\nwebsocketd --maxframesize=-1 --port=8080 ./script.sh\n// after\nwebsocketd --maxframesize=0 --port=8080 ./script.sh","handlingStrategy":"validation","validationCode":"if (maxFrameSize < 0) throw new Error('--maxframesize must not be negative; use 0 for unlimited');","typeGuard":"const validFrameSize = (n) => Number.isInteger(n) && n >= 0;","tryCatchPattern":"try { startServer(args) } catch (e) { if (/maxframesize must not be negative/.test(e)) console.error('use 0 for unlimited, not -1'); throw e; }","preventionTips":["Never use -1 as 'unlimited' for this flag; the convention here is 0","Audit provisioning templates for defaults that substitute -1","Keep a positive limit in production to preserve DoS protection"],"tags":["cli","config-validation","websocket","dos-protection"],"backgroundTag":"invalid-flag-value","analyzedSha":"7a8683dc7f9778dc615945aaed2a8dc77290227b","analyzedAt":"2026-09-03T13:52:22.309Z","contentChangedAt":"2026-09-03T13:52:22.309Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}