Skip to content

Security features persistence#7

Open
mdhaiwat wants to merge 2 commits into
7i:masterfrom
mdhaiwat:security-features-persistence
Open

Security features persistence#7
mdhaiwat wants to merge 2 commits into
7i:masterfrom
mdhaiwat:security-features-persistence

Conversation

@mdhaiwat

Copy link
Copy Markdown

No description provided.

Dhaiwat and others added 2 commits June 24, 2026 17:29
Security fixes:
- Per-IP POST rate limiting (30 req/min sliding window, ratelimit.go)
- HTTP Basic Auth on admin endpoint with constant-time SHA-256 compare
- TLS 1.2+ AEAD-only cipher suites (GCM + ChaCha20-Poly1305), X25519 first
- ReadTimeout/WriteTimeout/IdleTimeout on all HTTP servers
- Blocklist support (BlockedDomains config + optional BlocklistFile)
- All URL inputs validated; javascript: and other schemes rejected
- compress/decompress uses base64(gzip) to prevent JSON corruption of binary bytes
- Decompression bomb protection: 20 MiB cap via io.LimitReader
- lookupLink returns a snapshot copy (eliminates post-RLock field-read races)
- recordAccess decides Times consumption under the write lock (removes racy parameter)
- Add() snapshots Link before saveLinkToDB goroutine (prevents NextClear write race)
- Authoritative duplicate custom-key check inside Add() under write lock
- Salt and HashSHA256 redacted from startup log
- Correct HTTP status codes: 400 for invalid key, 404 for not-found, 403 for blocklist

New features:
- bbolt persistence (db.go rewrite): links survive restarts; prunes expired entries on boot
- JSON API: POST /api/v1/shorten, GET /api/v1/lookup/{key} (api.go)
- QR code endpoint: GET /qr/{key} returns 256x256 PNG (qr.go)
- Click analytics: AccessCount tracked per link, exposed via API
- URL deduplication: repeated submissions of same unlimited URL return existing key
- Security headers: X-Content-Type-Options, Referrer-Policy, optional HSTS/CSP/Report-To

Cleanup:
- Removed dead globals (TextBlobs, BackupLink* slices)
- validate() uses pre-built O(k) charset map instead of O(k*n) scan
- go/build replaced with os.UserHomeDir() in findFolderDefaultLocations
- getActiveList uses strings.Builder; shows <compressed> for compressed blobs
- Go version bumped to 1.23; dependencies: bbolt v1.4.3, go-qrcode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant