Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-20 - MONGODB_URI Password Disclosure Risk via Partial String Masking
**Vulnerability:** The public unauthenticated `/debug` endpoint was outputting `process.env.MONGODB_URI.substring(0, 60)`, intending to show a truncated preview of the string. However, since MongoDB URIs take the format `mongodb+srv://<username>:<password>@<cluster>.mongodb.net/...`, the first 60 characters usually include the entire username and plaintext password.
**Learning:** Developers sometimes assume taking the beginning of a string is safe for logging, failing to consider the internal structure of the secret (like connection URIs) where the most sensitive data is at the very beginning.
**Prevention:** Never use substring on connection strings or URLs to mask them. Either log a boolean (presence check) or use a dedicated parser to extract non-sensitive parts (like the host) if partial logging is truly needed.
2 changes: 1 addition & 1 deletion src/app/debug/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function GET() {

// Database
MONGODB_URI: process.env.MONGODB_URI
? `βœ… SET (${process.env.MONGODB_URI.substring(0, 60)}...)`
? 'βœ… SET (hidden for security)'
: '❌ NOT SET',

// Derived info
Expand Down