惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Vercel News
Vercel News
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
M
MIT News - Artificial intelligence
The Cloudflare Blog
N
Netflix TechBlog - Medium
GbyAI
GbyAI
Help Net Security
Help Net Security
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
Martin Fowler
Martin Fowler
量子位
P
Palo Alto Networks Blog
Security Latest
Security Latest
Attack and Defense Labs
Attack and Defense Labs
WordPress大学
WordPress大学
H
Help Net Security
C
Check Point Blog
T
Troy Hunt's Blog
C
CERT Recently Published Vulnerability Notes
Y
Y Combinator Blog
NISL@THU
NISL@THU
L
LINUX DO - 最新话题
V
Visual Studio Blog
C
Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
The Exploit Database - CXSecurity.com
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Announcements
Recent Announcements
Forbes - Security
Forbes - Security
IT之家
IT之家
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
L
LangChain Blog
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
Stack Overflow Blog
Stack Overflow Blog
H
Hacker News: Front Page
B
Blog
W
WeLiveSecurity
罗磊的独立博客
Jina AI
Jina AI
博客园 - 【当耐特】

博客园 - HappyQQ

Android安装器(mac版) V1.0.0 记住,永远别被新鲜的词汇吓住。 让 .Net 程序 脱离 .net framework框架 运行的方法[收藏] .net辅助工具列表 dahuzizyd [原作] KB-Modal Dialog Mini FAQ[收藏] 兼容的IE、FireFox的event事件[收藏] - HappyQQ - 博客园 我爱你——世界上最美丽的女人![收藏] WinForms开发人员的WebForms开发总结。 windows2003架設https服務(转) 设计模式概述 (收藏) GridView页脚汇总(统计)行的方法(.net 2.0) (转) C#多线程学习(一) 多线程的相关概念(转自xugang的blog) C#多线程之Thread(转) ACCESS数据库C#操作类(SQLHELPER修改版)——转自网上 c#.net连接access操作类(转) 三百个好用的免费软件名单[转] [转载]Top 15 free SQL Injection Scanners SQL注入的链接(收藏) 收集一下国外黑客网址
LDAP injection
HappyQQ · 2008-07-20 · via 博客园 - HappyQQ

LDAP injection

From OWASP

Jump to: navigation, search

This is an Attack. To view all attacks, please see the Attack Category page.

Last revision: 7/2/2008

Description

LDAP Injection is an attack used to exploit web based applications that construct LDAP statements based on user input. When an application fails to properly sanitize user input, it’s possible to modify LDAP statements using a local proxy. This could result in the execution of arbitrary command such as granting permissions to unauthorized queries, and content modification inside the LDAP tree. The same advanced exploitation techniques available in SQL Injection can be similarly applied in LDAP Injection.

Examples

Example 1

In a page with a user search form, the following code is responsible to catch input value and generate a LDAP query that will be used in LDAP database.

 <input type="text" size=20 name="userName">Insert the username</input> 

The LDAP query is narrowed down for performance and the underlying code for this function might be the following:

 String ldapSearchQuery = "(cn=" + $userName + ")";
 System.out.println(ldapSearchQuery); 

Case the variable $userName is not validated, it could be possible accomplish LDAP injection, as follows:

*If a user puts “*” on box search, the system may return all the usernames on the LDAP base
*If a user puts “jonys) (| (password = * ) )”, it will generate the code bellow revealing jonys’ password
( cn = jonys ) ( | (password = * ) )
Example 2

The following vulnerable code is used in an ASP web application which provides login with LDAP data base. On line 11, the variable userName is initialized and validated to check if it’s not in blank. Then, the content of this variable is used to construct a LDAP query used by SearchFilter on line 28. The attacker has the chance specify what will be queried on LDAP server, and see the result on the line 33 to 41, are all results and their attributes are displayed.

Commented vulnerable asp code:

 
 1.	<html>
 2.	<body>
 3.	<%@ Language=VBScript %>
 4.	<%
 5.	Dim userName
 6.	Dim filter
 7.	Dim ldapObj
 8.		
 9.	Const LDAP_SERVER = "ldap.example"
 10.	
 11.	userName = Request.QueryString("user")
 12.	
 13.	if( userName = "" ) then
 14.	Response.Write("Invalid request. Please specify a valid
 15.	user name")
 16.	Response.End()
 17.	end if
 18.	
 19.	filter = "(uid=" + CStr(userName) + ")" ' searching for the  user entry 
 20.	
 21.	'Creating the LDAP object and setting the base dn
 22.	Set ldapObj = Server.CreateObject("IPWorksASP.LDAP")
 23.	ldapObj.ServerName = LDAP_SERVER
 24.	ldapObj.DN = "ou=people,dc=spilab,dc=com"
 25.	
 26.	'Setting the search filter
 27.	ldapObj.SearchFilter = filter
 28.	
 29.	ldapObj.Search
 30.	
 31.	'Showing the user information
 32.	While ldapObj.NextResult = 1
 33.	Response.Write("<p>")
 34.	
 35.	Response.Write("<b><u>User information for: " + 
 36.	ldapObj.AttrValue(0) + "</u></b><br>")
 37.	For i = 0 To ldapObj.AttrCount -1
 38.	Response.Write("<b>" + ldapObj.AttrType(i) +"</b>: " +
 39.	ldapObj.AttrValue(i) + "<br>" )
 40.	Next
 41.	Response.Write("</p>")
 42.	Wend
 43.	%>
 44.	</body>
 45.	</html>   

In the example above, we send the * character in the user parameter which will result in the filter variable in the code to be initialized with (uid=*). The resulting LDAP statement will make the server return any object that contains a uid attribute like username.

 http://www.some-site.org/index.asp?user=*  

Related Threat Agents

Related Attacks

Related Vulnerabilities

Category:Input Validation Vulnerability

Related Controls

References

Retrieved from "http://www.owasp.org/index.php/LDAP_injection"

Categories: OWASP ASDR Project | Injection | Attack