๐ Security Improvements
CSRF Token Protection
This release implements comprehensive CSRF (Cross-Site Request Forgery) token protection across the entire application. All mutation requests (POST, PUT, DELETE, PATCH) now properly include CSRF tokens to prevent unauthorized actions.
Key Changes:
- Created reusable
useCsrfFetchhook for React components - Added
getHeadersWithCsrf()helper to API service for centralized token management - Implemented automatic token refresh on 403 errors in API service
- Added fallback to sessionStorage for token persistence
BASE_URL Compatibility
Fixed 403 Forbidden errors when running the application with a custom BASE_URL (e.g., /meshmonitor) in reverse proxy configurations.
Improvements:
- Automatic BASE_URL detection from pathname
- Intelligent app route filtering for multi-segment paths
- Consistent CSRF endpoint discovery across all contexts
๐ ๏ธ Components Updated
React Components (7 files)
- App.tsx - Message sending with CSRF protection
- SettingsTab.tsx - Settings save/reset operations
- AutoTracerouteSection.tsx - Traceroute interval configuration
- AutoAcknowledgeSection.tsx - Auto-acknowledge settings
- AutoAnnounceSection.tsx - Auto-announce settings
- Dashboard.tsx - Telemetry favorites management
- TelemetryGraphs.tsx - Chart favoriting functionality
API Service Methods (22 updated)
All mutation methods now include CSRF tokens:
- Message operations:
sendMessage(),sendTraceroute() - Node management:
refreshNodes(),purgeNodes() - Data operations:
purgeTelemetry(),purgeMessages(),clearRecordHolderSegment() - Device config:
setDeviceConfig(),setLoRaConfig(),setPositionConfig(),setMQTTConfig(),setNeighborInfoConfig(),setNodeOwner() - System operations:
rebootDevice(),restartContainer(),disconnectFromNode(),reconnectToNode() - Config requests:
requestConfig(),requestModuleConfig() - Settings:
updateTracerouteInterval(),setTracerouteIntervalMinutes()
๐ Bug Fixes
Rate Limiter Configuration
Fixed rate limiter validation issues when running behind reverse proxies with TRUST_PROXY=1:
- Disabled express-rate-limit built-in validation (
validate: false) - Properly configured
trustProxyoption for accurate client IP detection - Prevents "Misconfigured express-rate-limit" errors
CSRF Context
- Fixed CsrfProvider to properly detect BASE_URL from API service
- Added robust error handling with sessionStorage fallback
- Improved logging for debugging CSRF-related issues
๐ Configuration
Environment Variables
This release works seamlessly with:
BASE_URL- Custom path prefix (e.g.,/meshmonitor)TRUST_PROXY=1- For reverse proxy deploymentsCOOKIE_SECURE=true/false- Flexible cookie security settingsALLOWED_ORIGINS- Comma-separated list of allowed CORS origins
Deployment Scenarios Tested
โ
Root path deployment (BASE_URL=/)
โ
Subpath deployment (BASE_URL=/meshmonitor)
โ
HTTP development environments
โ
HTTPS production environments
โ
Reverse proxy configurations (nginx, Traefik, etc.)
๐ Upgrade Notes
Breaking Changes
None - this is a backward-compatible security enhancement.
Recommendations
- Ensure
TRUST_PROXYis set correctly if behind a reverse proxy - Configure
ALLOWED_ORIGINSto match your deployment domain(s) - Test CSRF-protected operations (sending messages, saving settings) after upgrade
๐ Testing
All 614 tests passing:
- โ Component integration tests
- โ API service tests
- โ Authentication & authorization tests
- โ Server-side security tests
๐ What's Next
v2.4.4 (Planned Improvements)
- Enhanced error recovery for CSRF token refresh in App.tsx
- Improved token management consistency
- Reduced production logging verbosity
- Additional test coverage for edge cases
๐ Full Changelog
See PR #188 for detailed code changes and discussion.
๐ค Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
๐ MeshMonitor v2.4.3
๐ฆ Installation
Docker (recommended):
docker run -d \
--name meshmonitor \
-p 8080:3001 \
-v meshmonitor-data:/data \
ghcr.io/Yeraze/meshmonitor:v2.4.3๐งช Testing
โ
All tests passed
โ
TypeScript checks passed
โ
Docker images built for linux/amd64, linux/arm64, linux/arm/v7
๐ Changes
See commit history for detailed changes.