Valenfind
CTF WRITEUP

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.

TryHackMe Easy Web Application Security LFI Flask SQLite

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:

  1. Reconnaissance
  2. Directory and endpoint enumeration
  3. Application exploration
  4. Network request inspection
  5. Local File Inclusion discovery
  6. Flask source-code analysis
  7. Administrative endpoint discovery
  8. SQLite database investigation
  9. Security-impact analysis
  10. 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.

Portfolio Objective
Demonstrate practical experience with web application security, Linux enumeration, Flask application review, Local File Inclusion, API testing, SQLite analysis, and secure-coding remediation.

Quick Overview

Platform
TryHackMe
Room
Valenfind
Difficulty
Easy
Category
Web Application Security
Primary Vulnerability
Local File Inclusion (LFI)
Framework
Python Flask
Database
SQLite
Operating System
Linux

Skills Demonstrated

Linux Enumeration Nmap Gobuster Browser Developer Tools HTTP Analysis LFI Directory Traversal Flask Source Review API Testing SQLite Investigation Secure Coding


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
→
Directory Enumeration
→
Request Inspection
→
LFI
→
Source Disclosure
→
Secret Discovery
→
Admin API Access
→
Database Export
→
Sensitive Data Disclosure
Valenfind attack flow showing the documented progression from reconnaissance to sensitive information disclosure
Figure — Documented Valenfind attack flow from reconnaissance through database disclosure.

Reconnaissance

The assessment began by identifying exposed services and web application entry points.

Nmap Enumeration

Nmap scan performed during Valenfind reconnaissance
Figure — Nmap reconnaissance used to identify the exposed application service.

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

Gobuster directory enumeration performed against the Valenfind application
Figure — Directory and resource enumeration performed during reconnaissance.

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

Valenfind application homepage
Figure — Initial landing page of the Valenfind dating application.

The homepage provided the initial interface for interacting with the application.


User Registration

Valenfind user registration page
Figure — User registration interface used to establish a normal application account.

A normal user account was created to enable authenticated testing of functionality that was unavailable to unauthenticated users.


Complete Profile

Valenfind profile completion page
Figure — Profile completion interface containing additional user-controlled fields.

Profile completion introduced additional user-controlled application functionality.


Login

Valenfind login page
Figure — Authentication interface for accessing authenticated functionality.

Successful authentication provided access to the application’s internal user functionality.


User Dashboard

Valenfind authenticated user dashboard
Figure — Authenticated Valenfind dashboard displaying application functionality.

The dashboard provided access to the authenticated application environment.


Profile Page

Valenfind user profile page with profile theme functionality
Figure — Profile functionality containing the Profile Theme selector that became relevant to the later security analysis.

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

Browser network inspector showing the Valenfind layout request
Figure — Network inspection revealing the dynamic layout request.

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.

Key Finding — User-Controlled File Parameter
The application accepted a filename through the `layout` parameter. Parameters that influence server-side file selection should be carefully validated because insufficient validation can expose filesystem resources outside the application's intended directory.

Local File Inclusion

The layout parameter was subsequently evaluated for directory traversal and Local File Inclusion behavior.

LFI Request

Valenfind Local File Inclusion request
Figure — Request demonstrating the documented Local File Inclusion testing.

The parameter was tested with directory traversal payloads in an attempt to access files outside the intended templates directory.


Confirming Local File Inclusion

Response showing access to the Linux etc passwd file through the LFI vulnerability
Figure — Successful access to /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
Security Impact
A file-loading parameter intended for application layouts could be redirected toward local filesystem resources. This transformed a seemingly limited theme-loading feature into a source of sensitive server-side information disclosure.

Process Enumeration

Valenfind LFI access to proc self cmdline
Figure — Reading /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

Flask application source code obtained during the Valenfind analysis
Figure — Flask application source-code analysis performed after establishing local file read.

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

Flask routes identified during source code analysis
Figure — Flask route review revealing application and administrative functionality.

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

Redacted hardcoded administrative secret identified in Flask source code
Figure — Hardcoded administrative secret identified in application source; sensitive information remains redacted.

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.

Responsible Disclosure
Administrative secrets and challenge-sensitive information have intentionally been redacted from this portfolio presentation where the original documentation indicates that they were redacted.

Administrative Endpoint Discovery

Source-code review exposed a hidden administrative API endpoint.

Hidden Administrative Route

Hidden administrative endpoint identified during Valenfind source code analysis
Figure — Administrative endpoint identified through Flask source-code review.

The endpoint required a custom authentication header.

The combination of:

  1. Local File Inclusion
  2. Source-code disclosure
  3. Hardcoded administrative secret

provided the information necessary to interact with this restricted functionality.


Authenticated Administrative Request

Authenticated request to the Valenfind administrative endpoint
Figure — Authenticated administrative request demonstrating access to backend database functionality.

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

Valenfind SQLite database download
Figure — Backend SQLite database obtained through the administrative endpoint.

The administrative functionality allowed the backend database to be downloaded for local analysis.


SQLite Investigation

SQLite database opened for local investigation
Figure — SQLite database opened for schema and record analysis.

The database investigation included:

  • Table identification
  • Schema inspection
  • User-record analysis

Database Schema

Valenfind users table schema
Figure — Documented schema of the users data within the SQLite database.

The documented user-data schema included fields such as:

  • Username
  • Email
  • Phone Number
  • Address
  • Biography
  • Avatar

The presence of these fields demonstrated that unauthorized database access could expose significant user information.


Sanitized User Records

Redacted Valenfind user records
Figure — Sanitized user records used as portfolio evidence while protecting sensitive information.

Sensitive information has intentionally been removed from the portfolio documentation.

Responsible Disclosure
Personally identifiable information, administrative secrets, passwords, and challenge flags have been redacted from the portfolio where applicable.

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
Primary Security Observation
The most important lesson from the assessment is the way multiple weaknesses chained together. The initial file-loading flaw enabled local file disclosure, which enabled source-code discovery, which exposed an administrative secret, which in turn enabled access to backend database functionality.

Security Impact

Attack Chain Visualization

Valenfind security attack chain from reconnaissance through sensitive information disclosure
Figure — Complete documented attack chain and resulting security impact.

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
Nmap Gobuster Browser Developer Tools Flask SQLite

Key Findings

Finding 01 — User-Controlled Layout Loading
The application exposed a `layout` parameter through the `/api/fetch_layout` endpoint. This parameter became the entry point for directory traversal and Local File Inclusion testing.
Finding 02 — Arbitrary Local File Read
The documented ability to retrieve `/etc/passwd` confirmed that the layout-loading functionality could access files outside its intended directory.
Finding 03 — Source-Code Disclosure
The local file-read capability enabled access to the Flask application's source code, exposing application logic and additional routes.
Finding 04 — Hardcoded Administrative Secret
The application source contained an administrative token that was subsequently relevant to accessing the hidden administrative functionality.
Finding 05 — Database Exposure
Authenticated access to the administrative functionality resulted in the application's SQLite database being returned, exposing backend user information.

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:

Input Validation Failure
→
LFI
→
Source Disclosure
→
Secret Exposure
→
Admin API
→
Database Exposure

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.