Valenfind
A professional security analysis of the Valenfind TryHackMe room, documenting reconnaissance, web application analysis, Local File Inclusion, source-code disclosure, administrative API access, SQLite investigation, security impact, and remediation.
Mission
The objective of this walkthrough is to document the complete security assessment of the Valenfind TryHackMe room.
The assessment follows a structured penetration-testing workflow:
- Reconnaissance
- Directory and endpoint enumeration
- Application exploration
- Network request inspection
- Local File Inclusion discovery
- Flask source-code analysis
- Administrative endpoint discovery
- SQLite database investigation
- Security-impact analysis
- Remediation recommendations
The documentation is designed to demonstrate not only how the application was compromised within the lab, but also why each step mattered from a security perspective.
Quick Overview
Skills Demonstrated
Navigation
- Mission
- Quick Overview
- Attack Surface
- Attack Chain
- Reconnaissance
- Application Exploration
- Network Traffic Analysis
- Local File Inclusion
- Source Code Analysis
- Administrative Endpoint Discovery
- SQLite Database Analysis
- Security Findings
- Security Impact
- Remediation Recommendations
- Tools Used
- Key Findings
- Lessons Learned
- Repository Structure
- Full Technical Documentation
- Responsible Use
- Conclusion
Attack Surface
The Valenfind application is documented as a Python Flask web application running on port 5000.
The assessment identified the following application attack surface:
| Attack Surface | Description |
|---|---|
| Authentication | Registration and login functionality |
| User Dashboard | Authenticated application functionality |
| User Profiles | Profile-management functionality |
| Profile Theme | User-controlled theme selection |
| Dynamic Layout Endpoint | /api/fetch_layout |
| Administrative API | Restricted administrative functionality |
| Backend Database | SQLite database |
The most significant attack surface discovered during application analysis was the dynamic layout-loading functionality.
Attack Chain
Reconnaissance
The assessment began by identifying exposed services and web application entry points.
Nmap Enumeration
Objective
The purpose of the initial scan was to identify:
- Running services
- Exposed ports
- Available application entry points
Result
The reconnaissance phase identified:
- Port 5000
- A Flask web application
This established the primary web application as the initial attack surface.
Gobuster Directory Enumeration
Objective
Gobuster was used to identify additional application resources and exposed routes.
Result
The enumeration identified additional application attack surface, including:
- Authentication-related endpoints
- API routes
- Additional application resources
The discovered routes provided additional areas for subsequent application analysis.
Application Exploration
Before actively testing the application’s security controls, the application was explored through normal user functionality.
This established an understanding of the expected application workflow and identified user-controlled functionality that could later be examined from a security perspective.
Homepage
The homepage provided the initial interface for interacting with the application.
User Registration
A normal user account was created to enable authenticated testing of functionality that was unavailable to unauthenticated users.
Complete Profile
Profile completion introduced additional user-controlled application functionality.
Login
Successful authentication provided access to the application’s internal user functionality.
User Dashboard
The dashboard provided access to the authenticated application environment.
Profile Page
The Profile Theme selector was particularly important because it interacted with server-side functionality responsible for retrieving application layouts.
Network Traffic Analysis
Browser Developer Tools were used to inspect the communication between the browser and the Flask application.
Network Inspector
The network inspection revealed the following request:
/api/fetch_layout?layout=theme_classic.html
The layout parameter was user-controlled and therefore became an important security-testing target.
Local File Inclusion
The layout parameter was subsequently evaluated for directory traversal and Local File Inclusion behavior.
LFI Request
The parameter was tested with directory traversal payloads in an attempt to access files outside the intended templates directory.
Confirming Local File Inclusion
/etc/passwd, confirming arbitrary local file read behavior.
Access to /etc/passwd confirmed that the application could be manipulated into reading files outside its intended template location.
Security Significance
The behavior demonstrated:
- Directory Traversal
- Local File Inclusion
- Improper input validation
- Arbitrary local file read capability
Process Enumeration
/proc/self/cmdline to identify the application's execution context.
The LFI capability was used to read:
/proc/self/cmdline
The resulting information exposed the application’s execution path and assisted in identifying the Flask project directory.
This provided a route from the initial file-read vulnerability toward application source-code discovery.
Source Code Analysis
The LFI vulnerability was leveraged to read the Flask application’s source code.
Source disclosure significantly expanded the available attack surface because application logic, routes, and sensitive implementation details became accessible.
Application Source
Security Findings
The source code exposed:
- Flask routes
- Application logic
- Sensitive implementation details
- Secrets stored directly in application source
The source-code disclosure therefore provided considerably more information than the original LFI issue alone.
Flask Route Review
Important functionality identified during source-code review included:
fetch_layout- Authentication routes
- A hidden administrative API
This demonstrated the value of source-code analysis after obtaining arbitrary local file read access.
Hardcoded Administrative Secret
The application source contained a hardcoded administrative token.
The token was relevant to the next stage because the hidden administrative endpoint required a custom authentication header.
Administrative Endpoint Discovery
Source-code review exposed a hidden administrative API endpoint.
Hidden Administrative Route
The endpoint required a custom authentication header.
The combination of:
- Local File Inclusion
- Source-code disclosure
- Hardcoded administrative secret
provided the information necessary to interact with this restricted functionality.
Authenticated Administrative Request
After supplying the recovered administrative token, the administrative endpoint returned the application’s SQLite database.
This represented a significant escalation in impact from the original file-read vulnerability.
SQLite Database Analysis
The exported SQLite database was investigated locally to understand the backend data exposed through the administrative functionality.
Database Download
The administrative functionality allowed the backend database to be downloaded for local analysis.
SQLite Investigation
The database investigation included:
- Table identification
- Schema inspection
- User-record analysis
Database Schema
The documented user-data schema included fields such as:
- Username
- Phone Number
- Address
- Biography
- Avatar
The presence of these fields demonstrated that unauthorized database access could expose significant user information.
Sanitized User Records
Sensitive information has intentionally been removed from the portfolio documentation.
Security Findings
The documented assessment identified multiple security weaknesses across the application’s attack chain.
| Finding | Documented Risk | Evidence / Impact |
|---|---|---|
| Local File Inclusion | High | Arbitrary local file read, including /etc/passwd |
| Directory Traversal | High | Access to files outside the intended templates directory |
| Source Code Disclosure | Critical | Flask application source became readable |
| Hardcoded Secrets | Critical | Administrative token was present in source code |
| Sensitive Data Exposure | High | SQLite database exposed user information |
| Insecure Administrative API | High | Administrative functionality permitted database access |
Security Impact
Attack Chain Visualization
The assessment demonstrated how a single input-validation weakness could become substantially more severe when combined with insecure development practices.
The documented chain resulted in:
- Source-code disclosure
- Administrative credential exposure
- Unauthorized database export
- Sensitive information disclosure
The key security lesson is that individual vulnerabilities should not always be assessed in isolation. A relatively narrow file-read vulnerability can provide the information necessary to reach significantly more sensitive application functionality.
Remediation Recommendations
The recommended controls below are derived directly from the documented vulnerabilities.
| Issue | Recommended Mitigation |
|---|---|
| Local File Inclusion | Validate filenames against an allowlist |
| Directory Traversal | Canonicalize paths and restrict filesystem access |
| Hardcoded Secrets | Store secrets in environment variables or a dedicated secrets manager |
| Administrative API | Enforce authentication and role-based authorization |
| SQLite Export | Restrict database exports and audit administrative actions |
| Sensitive Information Exposure | Encrypt sensitive data and implement least-privilege access |
Local File Inclusion
The application should avoid accepting arbitrary filesystem paths from user-controlled input.
A strict allowlist of permitted layout identifiers should be preferred over accepting arbitrary filenames.
Where filesystem access is required, paths should be canonicalized and verified against an explicitly permitted application directory.
Directory Traversal
The application should prevent traversal outside the intended resource directory.
Filesystem operations should:
- Resolve the requested path
- Verify that the resulting canonical path remains inside the permitted directory
- Reject unexpected path components
- Prefer application-level identifiers over raw filesystem paths
Hardcoded Administrative Secrets
Administrative secrets should not be embedded directly in application source code.
The documented recommendation is to use:
- Environment variables
- A secrets-management system
- Proper secret rotation
- Restricted access to production credentials
This also reduces the impact of accidental source-code disclosure.
Administrative API Security
Administrative functionality should enforce strong authentication and authorization.
The endpoint should verify:
- Authentication
- Administrative authorization
- Appropriate role or privilege
- Request legitimacy
Administrative operations should also be logged and monitored.
Database Export Controls
Database export functionality should be tightly restricted.
Recommended controls include:
- Restricting exports to authorized administrators
- Auditing administrative export operations
- Limiting database access according to least privilege
- Protecting exported database files
- Preventing unnecessary exposure of backend storage
Sensitive Information Protection
Sensitive user information should be protected through appropriate access controls and data-protection mechanisms.
The documented remediation recommends:
- Encrypting sensitive data where appropriate
- Applying least-privilege access
- Restricting administrative access
- Preventing unauthorized database disclosure
Tools Used
The following tools and technologies are explicitly documented in the original walkthrough.
| Tool / Technology | Purpose |
|---|---|
| Nmap | Network and service reconnaissance |
| Gobuster | Directory and application-resource enumeration |
| Browser Developer Tools | HTTP/network request inspection |
| Python Flask | Application framework analyzed during source review |
| SQLite | Backend database investigated after administrative access |
Key Findings
Lessons Learned
Reconnaissance Comes First
Initial service and directory enumeration established the available application attack surface before deeper testing began.
Understanding exposed functionality reduced unnecessary testing and helped identify the application entry points.
Normal Application Behavior Can Reveal Attack Surface
Exploring the application as a legitimate user exposed the Profile Theme functionality.
The subsequent network inspection revealed that the theme selection interacted with a server-side layout-loading endpoint.
User-Controlled File Parameters Require Careful Validation
The layout parameter demonstrated why applications should not blindly trust user-controlled filenames.
A feature that appears to load a simple application template can become a serious security issue when filesystem boundaries are not enforced.
Source Code Can Amplify a Vulnerability
The LFI vulnerability initially provided file-read capability.
Once application source code became accessible, additional functionality and a hardcoded administrative secret could be identified.
This demonstrates why source-code disclosure can significantly increase the impact of another vulnerability.
Vulnerabilities Can Chain Together
The Valenfind assessment demonstrates a complete vulnerability chain:
The overall impact was substantially greater than the initial vulnerability considered independently.
Defensive Understanding
From a defensive perspective, the room reinforces the importance of:
- Strict input validation
- Filesystem boundary enforcement
- Secure secret management
- Strong administrative authorization
- Database-access controls
- Protection of sensitive user information
Repository Structure
The documented repository structure is:
Valenfind-TryHackMe-Walkthrough/
├── README.md
├── Documentation/
│ └── Valenfind_Documentation.md
├── Resources/
│ └── notes.md
├── docs/
│ ├── index.md
│ └── assets/
│ ├── room-banner.png
│ ├── recon/
│ ├── application/
│ ├── lfi/
│ ├── source-analysis/
│ ├── database/
│ └── remediation/
└── LICENSE
The GitHub Pages documentation uses the assets stored beneath docs/assets/.
Full Technical Documentation
The repository also contains the complete technical walkthrough with the detailed methodology, commands, explanations, and supporting screenshots.
View Complete Technical Documentation
Room Reference
The original documentation identifies the challenge as the Valenfind room on TryHackMe.
Platform: TryHackMe
Room: Valenfind
Responsible Use
This documentation was created for authorized cybersecurity training and CTF environments. Techniques described here should only be used against systems for which you have explicit permission to test.
The techniques demonstrated in this documentation are intended for controlled educational environments and security research.
Sensitive information shown in the original material has been intentionally redacted where applicable for responsible portfolio publication.
Conclusion
The Valenfind room demonstrates how a seemingly narrow input-validation issue can develop into a broader application compromise when combined with insecure development practices.
The documented attack began with reconnaissance and application enumeration, progressed through network request analysis and Local File Inclusion, and ultimately enabled Flask source-code disclosure, administrative secret discovery, administrative API access, and SQLite database exposure.
The assessment highlights several important application-security principles:
- User-controlled filesystem parameters require strict validation.
- Directory traversal must be prevented through secure path handling.
- Application source code should not expose secrets.
- Administrative functionality requires strong authentication and authorization.
- Backend databases should never be unnecessarily exposed.
- Sensitive user information requires appropriate access controls.
From a penetration-testing perspective, the room demonstrates the importance of following evidence from one stage of an assessment into the next rather than treating individual findings as isolated issues.
From a defensive perspective, it demonstrates how multiple weaknesses can combine to produce a substantially larger security impact.