SlideShare a Scribd company logo
1 of 48
Download to read offline
Understanding Persistent Cookies
and LDAP injection
A session by:
Maulik Lakhani
Security Analyst and former Team
Lead
Passionate Cybersecurity Analyst working in VAPT, Application Security Assessment domain. Worked as Team
Lead in 2 organizations. Handled team of 15-20 in 3 organizations. Skilled at VAPT of Web, Android and APIs. I
specialize in JS encryption, GraphQL, custom Frida scripts and, root detection bypass, and SafetyNet bypass.
Currently working as SecurityAnalyst 3
at Ernst andYoungGDS
Worked as Associate Information
Security Analyst at Indusface
https://www.linkedin.com/in/mauliklakhani/ https://twitter.com/MaulikxLakhani
Worked as Brand Executive at
Alma Mater Biz Solutions
➢ Outline
Understanding cookies
How persistent cookies work?
Understanding Active Directory and LDAP
How LDAP Injection work?
Questions andAnswer session
SessionCookies
• Temporary cookie files stored in browser memory and never written to disk.
• Gets erased when you close browser. If you go back to the site, it’ll not recognize
you.
Persistent cookies
• Stay on your hard drive (one of your browser's subfolders) until they expire or
get deleted.
➢ Understanding cookies
SessionCookies
• If a cookie does not specify an expiration date, the cookie is removed once the
user quits browser. Hence, these are used for managing sessions.
Persistent cookies
• Have an future expiration date which controls how long they last.
• Cookie setter specifies a deletion date, the cookie will be removed on that
date.
➢ Are both cookies the same?
➢ Use cases for persistent cookies
User identification
User tracking
Menu preferences
Theme selection
Languagepreferences
Persistent cookies enable following functionalities:
➢ How persistent cookies work?
Login
Browser
sets
cookies
Browser is
closed,
session
cookies get
deleted
Persistent
cookies
remain
intact
User visits
the site
again
Persistent
cookies are
sent
Web app
recognizes
the user
➢ How non-persistent cookies work?
public void SetNonPersistentCookies(string name, string value)
{
HttpCookie cookie = new HttpCookie(name);
cookie.Value = value;
Response.Cookies.Add(cookie);
}
Setting up a session cookie in ASP.NET
Function call:
SetNonPersistentCookies(“ASPSESSIONID”,”47a04x3”);
➢ How persistent cookies work?
public void SetPersistentCookies(string name, string value)
{
HttpCookie cookie = new HttpCookie(name);
cookie.Value = value;
cookie.Expires = Convert.ToDateTime(“10/10/2020″);
Response.Cookies.Add(cookie);
}
Setting up a persistent cookie in ASP.NET
Function call:
SetPersistentCookies(“UserName”,”Maulik”);
SetPersistentCookies(“Language”,”en-us”);
➢ How persistent cookies work?
setcookie("emailCookie",$email, time()+60*60*24*365*10);
PHP code to set a cookie to expire in 10 years:
from django.http.response import HttpResponse
...
def view_method(request):
res = HttpResponse()
res.set_cookie("emailCookie",email, expires=time()+60*60*24*365*10, secure=True, httponly=True)
return res
Python code to set a cookie to expire in 10 years:
➢ Security Impact
Persistent cookies are often set to expire in the distant future.
If private information is stored in persistent cookies, attackers have a larger time window to steal it.
Persistent cookies are often used to profile users as they interact with a site.
Web application functionality might be exploited by manipulating the values of the persistent cookies.
This can lead to session and authorization related vulnerabilities.
➢ How to test
After login, check which cookies are stored as persistent cookies
Analyze the information stored in persistent cookies
Check whether the cookie value is related to a functionality or level of access
Examples: 1) UserID=50 2) isAdmin=true 3) isAdmin=1,
4) functionality=dashboard,account,users
Manipulate the values of the persistent cookies to exploit application functionality.
This can lead to authorization related vulnerabilities: Privilege Escalation, Account Takeover.
➢ Demo
➢ Got questions?
➢ Understanding Active Directory
Directory-based identity-related service.
Provides authentication and authorization mechanisms.
A database and set of services that connect users with the network resources
Allows management and storage of information.
Stores data as objects. An object is a single element, such as a user, group, application or device like a
printer.
➢ Understanding Active Directory
OU = Organizational Unit
➢ Understanding Active Directory
OU = Organizational Unit
➢ Understanding LDAP
Lightweight Directory Access Protocol is more efficient, consumes less resources than DAP.
A protocol to query (receive) information from LDAP Server.
LDAP Server stores authentication information such as usernames and passwords.
This allows different applications and services to connect to the LDAP server to validate users.
➢ How does LDAP work
LDAP mechanism is based on DN (distinguished name). It’s like a unique identifier.These are sometimes used to
access resources, like a username.A DN might look like:
▪ CommonOperators:
o “=” (equal to)
o & (logical and)
o | (logical or)
o ! (logical not)
o * (wildcard)
▪ Filters:
cn=RichardFeynman,ou=Physics Department,dc=Caltech,dc=edu
uid=inewton,ou=MathematicsDepartment,dc=Cambridge,dc=com
LDAP queries submitted to the server are known as LDAP
search filters, which are constructed using prefix notation.
o CN = Common Name
o OU = Organizational Unit
o DC = Domain Component
o UID = User ID
➢ How LDAP authentication works
Account holder enters the credentials. LDAP server validates the account credentials.
If credentials are correct, authentication is successful.
login.php?name=admin&password=secret
find("(&(cn=" + username +")(userPassword=" + pass +"))")
➢ LDAP Injection in Authentication
➢ LDAP Injection in Authentication
➢ LDAP Injection in Authentication
Hey! Does this user exists in your records?
Let me
check…
Checking…
YES!
Alright! then user is valid. I’ll approve
login and assign session ID.Thanks!
Session_ID=A2b4384knb89123g
➢ LDAP Injection in Authentication
An example of an LDAP search filter:
This prefix filter notation instructs the query to find an LDAP node with the given username and password.
o If user-controlled values are appended to the LDAP search filter without any validation or sanitization,
a value of ‘*’ changes the intended meaning of the query and returns a list of all users.
▪ Attack Scenario:
o If the username value is set to admin)(&)) the effective search filter becomes:
(&user=admin)(&))(Password=))
The highlighted condition in the above query evaluates to true.The attacker
gains access without having valid password.
o A tester can use a trial-and-error approach, by inserting '(', '|', '&', '*' and the other characters to check
the application for errors.
(&(User=Uname)(Password=Pwd))
➢ LDAP Injection in Authentication
Attacker injects a payload
Application accepts the payload, ignores the password.
Performs a search for Admin account.
Upon success authentication; Session will be created. If admin account is present, LDAP server will proceed to bind the
connection, application will think that credentials are correct.
➢ Security Impact
Information disclosure
Authentication bypass
Bypass access controls and gain access to higher privilege accounts
LDAP servers often store information such as users, roles, permissions, and related objects provisioned to them.
➢ Demo
Default value is passed here.
|(cn=2F204)(cn=“1FA04”))
|(cn=2F204)(cn=“)”))
These characters need escaping. Hence, they can be used for fuzzing:
• Space (' ')
• Number sign: #
• Double quote: “
• Plus sign: +
• Comma: ,
• Semicolon: ;
• Less than and greater than: < >
• Backward slash:
|(cn=2F204)(cn=“*”))
Payload:
Payload Search Filter
* (attribute=*)
value)(cn=* (attribute=value)(attribute2=*)
➢ Remediation for LDAP Injection
Strictly validate user input.
Allow only alphanumeric strings to be copied into queries, any other input should be rejected.
User input containing LDAP metacharacters like ( ) ; , * | & = “ and whitespace should be rejected.
Use component like LINQ to Active Directory that automatically escapes user input.
Least privilege: Minimize the privileges assigned to the LDAP binding account
➢ Recommended steps:
LDAP Injection:
https://www.blackhat.com/presentations/bh-europe-08/Alonso-Parada/Whitepaper/bh-eu-08-alonso-
parada-WP.pdf
HackThe Box:
Phonebook Challenge:https://app.hackthebox.eu/challenges/phonebook
➢ Got questions?
Persistant Cookies and LDAP Injection

More Related Content

What's hot

Intrusion detection
Intrusion detectionIntrusion detection
Intrusion detection
Umesh Dhital
 
Hive ICDE 2010
Hive ICDE 2010Hive ICDE 2010
Hive ICDE 2010
ragho
 

What's hot (20)

Ceh v8 labs module 04 enumeration
Ceh v8 labs module 04 enumerationCeh v8 labs module 04 enumeration
Ceh v8 labs module 04 enumeration
 
ELK Stack - Kibana操作實務
ELK Stack - Kibana操作實務ELK Stack - Kibana操作實務
ELK Stack - Kibana操作實務
 
MySQL Optimizer Cost Model
MySQL Optimizer Cost ModelMySQL Optimizer Cost Model
MySQL Optimizer Cost Model
 
Understanding android security model
Understanding android security modelUnderstanding android security model
Understanding android security model
 
Maze Problem Presentation
Maze Problem PresentationMaze Problem Presentation
Maze Problem Presentation
 
The Diamond Model for Intrusion Analysis - Threat Intelligence
The Diamond Model for Intrusion Analysis - Threat IntelligenceThe Diamond Model for Intrusion Analysis - Threat Intelligence
The Diamond Model for Intrusion Analysis - Threat Intelligence
 
Intrusion detection
Intrusion detectionIntrusion detection
Intrusion detection
 
Introduction to Common Weakness Enumeration (CWE)
Introduction to Common Weakness Enumeration (CWE)Introduction to Common Weakness Enumeration (CWE)
Introduction to Common Weakness Enumeration (CWE)
 
Thick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptxThick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptx
 
The ATT&CK Latin American APT Playbook
The ATT&CK Latin American APT PlaybookThe ATT&CK Latin American APT Playbook
The ATT&CK Latin American APT Playbook
 
IDOR Know-How.pdf
IDOR Know-How.pdfIDOR Know-How.pdf
IDOR Know-How.pdf
 
iOS Application Static Analysis - Deepika Kumari.pptx
iOS Application Static Analysis - Deepika Kumari.pptxiOS Application Static Analysis - Deepika Kumari.pptx
iOS Application Static Analysis - Deepika Kumari.pptx
 
Chapter 6: OPERATIONS ON GRAPHS
Chapter 6: OPERATIONS ON GRAPHSChapter 6: OPERATIONS ON GRAPHS
Chapter 6: OPERATIONS ON GRAPHS
 
Hive ICDE 2010
Hive ICDE 2010Hive ICDE 2010
Hive ICDE 2010
 
Power JSON with PostgreSQL
Power JSON with PostgreSQLPower JSON with PostgreSQL
Power JSON with PostgreSQL
 
Pentesting GraphQL Applications
Pentesting GraphQL ApplicationsPentesting GraphQL Applications
Pentesting GraphQL Applications
 
Pentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang BhatnagarPentesting Rest API's by :- Gaurang Bhatnagar
Pentesting Rest API's by :- Gaurang Bhatnagar
 
Intrusion Detection Presentation
Intrusion Detection PresentationIntrusion Detection Presentation
Intrusion Detection Presentation
 
2023 COSCUP - Whats new in PostgreSQL 16
2023 COSCUP - Whats new in PostgreSQL 162023 COSCUP - Whats new in PostgreSQL 16
2023 COSCUP - Whats new in PostgreSQL 16
 
Burpsuite 101
Burpsuite 101Burpsuite 101
Burpsuite 101
 

Similar to Persistant Cookies and LDAP Injection

Application Security
Application SecurityApplication Security
Application Security
florinc
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.
Nelson Gomes
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
Jay Shirley
 

Similar to Persistant Cookies and LDAP Injection (20)

Centralizing users’ authentication at Active Directory level 
Centralizing users’ authentication at Active Directory level Centralizing users’ authentication at Active Directory level 
Centralizing users’ authentication at Active Directory level 
 
MongoDB World 2019: Securing Application Data from Day One
MongoDB World 2019: Securing Application Data from Day OneMongoDB World 2019: Securing Application Data from Day One
MongoDB World 2019: Securing Application Data from Day One
 
Securing Your Enterprise Web Apps with MongoDB Enterprise
Securing Your Enterprise Web Apps with MongoDB Enterprise Securing Your Enterprise Web Apps with MongoDB Enterprise
Securing Your Enterprise Web Apps with MongoDB Enterprise
 
End-to-End Identity Management
End-to-End Identity ManagementEnd-to-End Identity Management
End-to-End Identity Management
 
Application Security
Application SecurityApplication Security
Application Security
 
OWASP Secure Coding
OWASP Secure CodingOWASP Secure Coding
OWASP Secure Coding
 
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More SecureLow Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
 
Security Awareness
Security AwarenessSecurity Awareness
Security Awareness
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
OWASP Top 10 List Overview for Web Developers
OWASP Top 10 List Overview for Web DevelopersOWASP Top 10 List Overview for Web Developers
OWASP Top 10 List Overview for Web Developers
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.
 
Bootstrapping - Session 1 - Your First Week with Amazon EC2
Bootstrapping - Session 1 - Your First Week with Amazon EC2Bootstrapping - Session 1 - Your First Week with Amazon EC2
Bootstrapping - Session 1 - Your First Week with Amazon EC2
 
XP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applications
 
Code your Own: Authentication Provider for Blackboard Learn
Code your Own: Authentication Provider for Blackboard LearnCode your Own: Authentication Provider for Blackboard Learn
Code your Own: Authentication Provider for Blackboard Learn
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
 
Building IAM for OpenStack
Building IAM for OpenStackBuilding IAM for OpenStack
Building IAM for OpenStack
 
Owasp first5 presentation
Owasp first5 presentationOwasp first5 presentation
Owasp first5 presentation
 
Owasp first5 presentation
Owasp first5 presentationOwasp first5 presentation
Owasp first5 presentation
 
It's a Dangerous World
It's a Dangerous World It's a Dangerous World
It's a Dangerous World
 
How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top Ten
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Buy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdfBuy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 

Persistant Cookies and LDAP Injection

  • 1. Understanding Persistent Cookies and LDAP injection A session by: Maulik Lakhani Security Analyst and former Team Lead
  • 2. Passionate Cybersecurity Analyst working in VAPT, Application Security Assessment domain. Worked as Team Lead in 2 organizations. Handled team of 15-20 in 3 organizations. Skilled at VAPT of Web, Android and APIs. I specialize in JS encryption, GraphQL, custom Frida scripts and, root detection bypass, and SafetyNet bypass. Currently working as SecurityAnalyst 3 at Ernst andYoungGDS Worked as Associate Information Security Analyst at Indusface https://www.linkedin.com/in/mauliklakhani/ https://twitter.com/MaulikxLakhani Worked as Brand Executive at Alma Mater Biz Solutions
  • 3. ➢ Outline Understanding cookies How persistent cookies work? Understanding Active Directory and LDAP How LDAP Injection work? Questions andAnswer session
  • 4. SessionCookies • Temporary cookie files stored in browser memory and never written to disk. • Gets erased when you close browser. If you go back to the site, it’ll not recognize you. Persistent cookies • Stay on your hard drive (one of your browser's subfolders) until they expire or get deleted. ➢ Understanding cookies
  • 5. SessionCookies • If a cookie does not specify an expiration date, the cookie is removed once the user quits browser. Hence, these are used for managing sessions. Persistent cookies • Have an future expiration date which controls how long they last. • Cookie setter specifies a deletion date, the cookie will be removed on that date. ➢ Are both cookies the same?
  • 6. ➢ Use cases for persistent cookies User identification User tracking Menu preferences Theme selection Languagepreferences Persistent cookies enable following functionalities:
  • 7. ➢ How persistent cookies work? Login Browser sets cookies Browser is closed, session cookies get deleted Persistent cookies remain intact User visits the site again Persistent cookies are sent Web app recognizes the user
  • 8. ➢ How non-persistent cookies work? public void SetNonPersistentCookies(string name, string value) { HttpCookie cookie = new HttpCookie(name); cookie.Value = value; Response.Cookies.Add(cookie); } Setting up a session cookie in ASP.NET Function call: SetNonPersistentCookies(“ASPSESSIONID”,”47a04x3”);
  • 9. ➢ How persistent cookies work? public void SetPersistentCookies(string name, string value) { HttpCookie cookie = new HttpCookie(name); cookie.Value = value; cookie.Expires = Convert.ToDateTime(“10/10/2020″); Response.Cookies.Add(cookie); } Setting up a persistent cookie in ASP.NET Function call: SetPersistentCookies(“UserName”,”Maulik”); SetPersistentCookies(“Language”,”en-us”);
  • 10. ➢ How persistent cookies work? setcookie("emailCookie",$email, time()+60*60*24*365*10); PHP code to set a cookie to expire in 10 years: from django.http.response import HttpResponse ... def view_method(request): res = HttpResponse() res.set_cookie("emailCookie",email, expires=time()+60*60*24*365*10, secure=True, httponly=True) return res Python code to set a cookie to expire in 10 years:
  • 11. ➢ Security Impact Persistent cookies are often set to expire in the distant future. If private information is stored in persistent cookies, attackers have a larger time window to steal it. Persistent cookies are often used to profile users as they interact with a site. Web application functionality might be exploited by manipulating the values of the persistent cookies. This can lead to session and authorization related vulnerabilities.
  • 12. ➢ How to test After login, check which cookies are stored as persistent cookies Analyze the information stored in persistent cookies Check whether the cookie value is related to a functionality or level of access Examples: 1) UserID=50 2) isAdmin=true 3) isAdmin=1, 4) functionality=dashboard,account,users Manipulate the values of the persistent cookies to exploit application functionality. This can lead to authorization related vulnerabilities: Privilege Escalation, Account Takeover.
  • 15. ➢ Understanding Active Directory Directory-based identity-related service. Provides authentication and authorization mechanisms. A database and set of services that connect users with the network resources Allows management and storage of information. Stores data as objects. An object is a single element, such as a user, group, application or device like a printer.
  • 16. ➢ Understanding Active Directory OU = Organizational Unit
  • 17. ➢ Understanding Active Directory OU = Organizational Unit
  • 18. ➢ Understanding LDAP Lightweight Directory Access Protocol is more efficient, consumes less resources than DAP. A protocol to query (receive) information from LDAP Server. LDAP Server stores authentication information such as usernames and passwords. This allows different applications and services to connect to the LDAP server to validate users.
  • 19. ➢ How does LDAP work LDAP mechanism is based on DN (distinguished name). It’s like a unique identifier.These are sometimes used to access resources, like a username.A DN might look like: ▪ CommonOperators: o “=” (equal to) o & (logical and) o | (logical or) o ! (logical not) o * (wildcard) ▪ Filters: cn=RichardFeynman,ou=Physics Department,dc=Caltech,dc=edu uid=inewton,ou=MathematicsDepartment,dc=Cambridge,dc=com LDAP queries submitted to the server are known as LDAP search filters, which are constructed using prefix notation. o CN = Common Name o OU = Organizational Unit o DC = Domain Component o UID = User ID
  • 20. ➢ How LDAP authentication works Account holder enters the credentials. LDAP server validates the account credentials. If credentials are correct, authentication is successful. login.php?name=admin&password=secret find("(&(cn=" + username +")(userPassword=" + pass +"))")
  • 21. ➢ LDAP Injection in Authentication
  • 22. ➢ LDAP Injection in Authentication
  • 23. ➢ LDAP Injection in Authentication Hey! Does this user exists in your records? Let me check… Checking… YES! Alright! then user is valid. I’ll approve login and assign session ID.Thanks! Session_ID=A2b4384knb89123g
  • 24. ➢ LDAP Injection in Authentication An example of an LDAP search filter: This prefix filter notation instructs the query to find an LDAP node with the given username and password. o If user-controlled values are appended to the LDAP search filter without any validation or sanitization, a value of ‘*’ changes the intended meaning of the query and returns a list of all users. ▪ Attack Scenario: o If the username value is set to admin)(&)) the effective search filter becomes: (&user=admin)(&))(Password=)) The highlighted condition in the above query evaluates to true.The attacker gains access without having valid password. o A tester can use a trial-and-error approach, by inserting '(', '|', '&', '*' and the other characters to check the application for errors. (&(User=Uname)(Password=Pwd))
  • 25. ➢ LDAP Injection in Authentication Attacker injects a payload Application accepts the payload, ignores the password. Performs a search for Admin account. Upon success authentication; Session will be created. If admin account is present, LDAP server will proceed to bind the connection, application will think that credentials are correct.
  • 26. ➢ Security Impact Information disclosure Authentication bypass Bypass access controls and gain access to higher privilege accounts LDAP servers often store information such as users, roles, permissions, and related objects provisioned to them.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Default value is passed here. |(cn=2F204)(cn=“1FA04”))
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 39.
  • 40. These characters need escaping. Hence, they can be used for fuzzing: • Space (' ') • Number sign: # • Double quote: “ • Plus sign: + • Comma: , • Semicolon: ; • Less than and greater than: < > • Backward slash:
  • 41.
  • 43.
  • 44. Payload: Payload Search Filter * (attribute=*) value)(cn=* (attribute=value)(attribute2=*)
  • 45. ➢ Remediation for LDAP Injection Strictly validate user input. Allow only alphanumeric strings to be copied into queries, any other input should be rejected. User input containing LDAP metacharacters like ( ) ; , * | & = “ and whitespace should be rejected. Use component like LINQ to Active Directory that automatically escapes user input. Least privilege: Minimize the privileges assigned to the LDAP binding account
  • 46. ➢ Recommended steps: LDAP Injection: https://www.blackhat.com/presentations/bh-europe-08/Alonso-Parada/Whitepaper/bh-eu-08-alonso- parada-WP.pdf HackThe Box: Phonebook Challenge:https://app.hackthebox.eu/challenges/phonebook