SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Tendances (20)

Waf bypassing Techniques
Waf bypassing TechniquesWaf bypassing Techniques
Waf bypassing Techniques
 
Cache poisoning
Cache poisoningCache poisoning
Cache poisoning
 
Express js
Express jsExpress js
Express js
 
A Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility CloakA Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility Cloak
 
A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...A2 - broken authentication and session management(OWASP thailand chapter Apri...
A2 - broken authentication and session management(OWASP thailand chapter Apri...
 
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
 
Dangling DNS records takeover at scale
Dangling DNS records takeover at scaleDangling DNS records takeover at scale
Dangling DNS records takeover at scale
 
Sql injection
Sql injectionSql injection
Sql injection
 
What should a hacker know about WebDav?
What should a hacker know about WebDav?What should a hacker know about WebDav?
What should a hacker know about WebDav?
 
CORS and (in)security
CORS and (in)securityCORS and (in)security
CORS and (in)security
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active Directory
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
 
SQL injection prevention techniques
SQL injection prevention techniquesSQL injection prevention techniques
SQL injection prevention techniques
 
Dns covert channels with scapy
Dns covert channels with scapyDns covert channels with scapy
Dns covert channels with scapy
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
LDAP Injection
LDAP InjectionLDAP Injection
LDAP Injection
 
SQL Injection and Clickjacking Attack in Web security
SQL Injection and Clickjacking Attack in Web securitySQL Injection and Clickjacking Attack in Web security
SQL Injection and Clickjacking Attack in Web security
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applications
 
CSRF, ClickJacking & Open Redirect
CSRF, ClickJacking & Open RedirectCSRF, ClickJacking & Open Redirect
CSRF, ClickJacking & Open Redirect
 
Broken access controls
Broken access controlsBroken access controls
Broken access controls
 

Similaire à 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
 

Similaire à 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
 

Dernier

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 

Dernier (20)

TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
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...
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
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
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 

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