Commit 58fe852
authored
Fix/security audit - 2026/04/11 (#13)
* fix(security): remediate all 16 findings from security audit
Address all findings from the 2026-04-11 security evaluation:
HIGH:
- SEC-001: Replace unbounded sync.Map PathCache with bounded LRU
(hashicorp/golang-lru) to prevent memory exhaustion DoS
MEDIUM:
- SEC-003: Make panic stack traces configurable via STATIC_DEBUG env var
- SEC-004: Generate random multipart boundary per response (crypto/rand)
- SEC-005: Add MaxCompressSize (10MB) limit for on-the-fly gzip
- SEC-006: Apply path.Clean in CacheKeyForPath to prevent cache poisoning
LOW:
- SEC-007: Suppress server name disclosure (empty Name field)
- SEC-008: Sanitize control characters in access log URIs
- SEC-009: Remove deprecated PreferServerCipherSuites TLS option
- SEC-010: Handle template execution errors in directory listing
- SEC-011: Add MaxServeFileSize (1GB) hard limit for large file serving
- SEC-012: Add clarifying comment on CORS wildcard Vary behavior
- SEC-013: Document ETag 64-bit truncation rationale
- SEC-014: Set explicit MaxRequestBodySize (1024 bytes)
- SEC-015: Add MaxConnsPerIP config support for rate limiting
- SEC-016: Validate symlink targets during cache preload
Also updates dependencies:
- brotli v1.2.0 → v1.2.1
- klauspost/compress v1.18.4 → v1.18.5
- fasthttp v1.69.0 → v1.70.0
* docs: update all documentation for security audit remediations
- Landing page (docs/index.html): add 3 new config fields to tables,
update security tabs (DoS, TLS, runtime), architecture pipeline
descriptions, and feature cards
- README.md: update architecture diagram, config tables (+3 fields),
env vars (+3 vars), DoS mitigations, and path-safety cache design
- USER_GUIDE.md: update config example, env vars table, preload section
(symlink validation, bounded LRU), add 413 troubleshooting entry
- config.toml.example: add max_compress_size to [compression] section
- CHANGELOG.md: add v1.6.2 entry covering all 16 security fixes,
dependency bumps, and documentation updates
* docs: revert CHANGELOG.md — will be auto-generated by Commitizen
* docs: mark all 16 security findings as resolved in audit report
Update SECURITY_EVAL_2026-04-11.md with resolution status for each
finding, upgrade overall grade from B+ to A, expand remediation plan
table with Status column covering all 16 items (previously grouped
SEC-012–016 as backlog).
* test: add tests and harden code review items
- Add TestBuildHandler_MaxServeFileSize (under/over/disabled)
- Add TestMiddleware_MaxCompressSize (under/over/at-limit/disabled)
- Expand TestCacheKeyForPath with path normalization edge cases
- Harden generateBoundary with math/rand/v2 fallback on crypto/rand failure
- Improve 413 response message with dynamic size limit
- Add log.Printf for template execution errors in directory listing
* test: add PathCache LRU and server security-defaults coverage
- Add TestPathCache_BoundedLRU: Len() never exceeds maxEntries after overflow
- Add TestPathCache_LookupPromotesEntry: LRU promotion keeps touched keys
- Add TestPathCache_FlushClearsAll: Purge empties cache completely
- Add TestPathCache_DefaultSizeOnZero: fallback to DefaultPathCacheSize
- Add TestNew_HTTPOnly_SecurityDefaults: Name, MaxRequestBodySize, MaxConnsPerIP
- Add TestNew_TLS_SecurityDefaults: same checks on both HTTP and HTTPS servers
- Add TestNew_MaxConnsPerIP_Zero: disabled state passes through correctly1 parent fcfe429 commit 58fe852
File tree
22 files changed
+1435
-70
lines changed- cmd/static-web
- docs
- internal
- cache
- compress
- config
- handler
- headers
- security
- server
22 files changed
+1435
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| 239 | + | |
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
| |||
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| 248 | + | |
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
| |||
263 | 266 | | |
264 | 267 | | |
265 | 268 | | |
| 269 | + | |
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
| |||
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
| 310 | + | |
306 | 311 | | |
307 | 312 | | |
308 | 313 | | |
| 314 | + | |
309 | 315 | | |
310 | 316 | | |
311 | 317 | | |
| |||
315 | 321 | | |
316 | 322 | | |
317 | 323 | | |
| 324 | + | |
318 | 325 | | |
319 | 326 | | |
320 | 327 | | |
| |||
0 commit comments