Security Breach: Detecting and Exploiting SQL Injection in Contact Groups

 
Workshop
 
Matej Groman, Juraj Komlosi
Kentico software
 
1
undefined
 
Agenda
 
Intro to penetration testing
Hands-on pentest of our application
6 exercises
Different types of vulnerabilities
 
2
undefined
 
Penetration testing
 
Focused on finding security vulnerabilities in application
Usually part of verification phase (S-SDLC)
Goal is to „think like an attacker“
Know how to locate vulnerable places
Know how to exploit it
OWASP - materials
 
Black / Grey / White box
 
3
undefined
 
OWASP Top 10 - 2021
 
1.
Broken Access Control
2.
Cryptographic Failures
3.
Injection
4.
Insecure
 
Design
5.
Security Misconfiguration
6.
Vulnerable and Outdated Components
7.
Identification and Authentication Failures
8.
S
oftware and Data Integrity Failures
9.
Security Logging and Monitoring Failures
10.
Server-Side Request Forgery
 
4
undefined
 
A01: Broken Access Control (IDOR)
 
User c
an access restricted data using direct access
GET 
https
://esh.op/shopping-cart?id=1
POST 
…/change-password
 
with
 body:
 
 
 
Fix: functional access control, least privilege principle
{
userId
: 
1
,
newPass
: 
****
}
 
5
undefined
 
Paypal – IDOR to add secondary users
 
Severity: 
7.1 (High)
Bounty: $10,500
https://hackerone.com/reports/415081
 
6
undefined
A03: 
Injection
 
Cross Site Scripting (XSS)
User input
:
Server HTML template:
 
Resulting HTML:
SQL Injection
User input
:
SQL query
:
File Injection
<script>
alert(„XSS“)</script>
<div> Hello 
{username} </div>
<div> Hello
<script>
alert(„XSS“)</script>
</div>
 OR 1=1 
--
SELECT * FROM users WHERE
 
username = ‘
{input}
AND password
7
undefined
 
reddit.com - Reflected XSS via URL path
 
Severity: 
7-8.9 (High)
Bounty: $5000
https://hackerone.com/reports/1051373
 
8
undefined
A04: Insecure design / Business logic
 
Problem is in design
E.g. missing security controls, breaking security best practices
 
Recover account – security questions
Attacker can gather those info using OSINT
Hashing URLs for authentication purposes
User can provide and hash arbitrary data – generate custom URLs
9
 
Pentest time!
 
 
10
undefined
 
How to set up environment
 
Download and install 
Burp Suite Community
Open embedded browser and go to the application
https://mffkenticoworkshop-
0
.azurewebsites.net/
Do not forget to change the instance number
 
You are ready to go!
 
11
undefined
 
We suspect that one of the macros used in Contact groups contains SQL
injection, try to find and exploit it!
This is a 
blind 
SQL injection - you won’t see the result in response, but
injected query will execute on background. 
If the query fails, it will be
logged to 
Event log
 
12
SQL Injection in Contact Macro
undefined
 
1.
Go to 
Contact
 
Groups
, create new group and go to Conditions.
2.
Select 
'Contact has value in field' 
macro.
It allows us to insert arbitrary input before operator in where clause (e.g. 
WHERE <field>
contains <value
>).
You can identify it by inserting `, recalculating group and then checking event log.
3.
Final payload (change FirstName of the administrator account)
1=1; UPDATE CMS_User SET FirstName='Joe' WHERE UserID = 53
--
F
inish the WHERE clause of the original query with any True statement, e.g. 1=1
Add ; to finish first query
Arbitrar
y query to drop table, dump data or anything
Comment out everything else with --
 
13
SQL Injection in Contact Macro - Solution
undefined
 
N
o user with lower permission set 
should be able to
 gain higher
permission
s
.
Your goal is to access 
Event log 
with
 use
r
user@localhost.local
Pass.word1
 
System is set so 
you can only access applications defined in
Digital Channel Manager 
role 
and
 
Users 
application
.
 
14
Privilege Escalation
undefined
 
1.
Go to 
Users
 and check your account details.
2.
You are able to modify which roles are assigned to you.
All roles (except Administrator) are available. There is already role for Role
Management, so you can assign it to you
3.
Now you have 
R
oles
 application available.
4.
You can create new role with permission to access 
Event log
 
15
Privilege Escalation - Solution
undefined
 
Account Takeover
 
In this challenge, you want to take over 
administrator
 account
using the
 
user@localhost.local
.
 
Start in the 
Users
 application
.
 
This can be done using standard UI (without modifying requests
)
 
16
undefined
 
Account Takeover - Solution
 
1.
Go to 
Users
 and check Administrator details.
2.
You can see that you are able to edit users with higher
privileges.
3.
Change 
email
 to any email 
in your possesion
4.
Go to forgotten password page and request password reset for
given email. (
The SMTP server is not set up, so c
heck 
email
queue 
where you can 
view the email
 link)
 
17
undefined
 
Stored XSS via Frontend Component
 
We are looking for one of the core components which contain a
XSS vulnerability.
You can 
e
xploit it 
as un-authenticated user 
from the Dancing Goat
site!
 (use private window)
Start by submitting payloads to 
Send us a message 
form
 
18
undefined
 
Stored XSS via Frontend Component
 
1.
Go to 
<base url>/contacts
 and inject
<img src=0 onerror=alert(1) /> 
into available fields
2.
Check 
Contact management
 in the administration
3.
Click account details – the payload will execute
 
19
undefined
 
Stored XSS via URL input
 
When we think about URL, we usually imagine some address
starting with 
http(s)://
, but these are not the only protocols that
can be used.
Try to find XSS by exploiting input that expects URL using 
Forms
application
.
 
20
undefined
 
Stored XSS via URL input - Solution
 
1.
Go to Forms/AfterFormSubmission and set the action to
“Redirect to URL”
2.
Insert payload starting with javascript: protocol.
javascript:alert(document.cookie)
Our input is then inserted something like this: <a href={value}../>
3.
Go to Dancing Goat site and submit a form. Alert will pop up.
 
21
undefined
 
Reflected XSS via Form Builder
 
TBD
 
22
undefined
 
File Injection
 
One of the biggest security concerns regarding web applications is
file upload
, which can lead to all kinds of vulnerabilities from
stored XSS to remote code execution (RCE).
 
Try to upload malicious 
xml file
 containing XSS, although .xml is
not listed as allowed extension for given content type.
 
In Pages, start by editing 
Cafe
 content type and uploading the file
here.
 
23
undefined
 
File Injection - Solution
 
1.
Open DevTools/Burp Suite proxy. Go to Pages and create new
Cafe item or edit existing one. In Photo content field try to
upload new file with .xml extension.
2.
Analyze request to 
/api/cmd 
and look for 
allowedExtensions
in JSON data.
3.
Resend / edit 
request and 
change png to xml
4.
If upload is successful, you will see a URL to the file in response.
Go check it 
(/getmedia/.../payload.xml
) to validate that the file was
uploaded and XSS is working.
 
24
undefined
 
Path traversal
 
View all folders in assets
using this attack in
Media Libraries
Exploit usually works by
“going up” in folder
structure (
../..
)
 
25
undefined
 
Path traversal - Solution
 
Go to Media Library, create new library
In Folder name insert following payload: 
..\..\.
 You will see
content (only folders in tree view) of folder assets in the site.
There is no limit, so feel free to see other folders
we are on Linux file system
Try deleting content by deleting Media library (destructive)
 
26
 
Thanks!
 
27
Slide Note
Embed
Share

Suspect a potential SQL injection in the macros used in Contact groups? Learn how to identify and exploit it through blind SQL injection techniques. Follow step-by-step instructions to execute a payload that alters user data and gain unauthorized access. Stay vigilant and proactively safeguard your data integrity.

  • Security
  • SQL Injection
  • Contact Groups
  • Exploitation
  • Macros

Uploaded on Apr 02, 2024 | 5 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. 1. Broken Access Control 3. Injection 4. Insecure Design

  2. { userId: 1, newPass: **** }

  3. We suspect that one of the macros used in Contact groups contains SQL injection, try to find and exploit it! This is a blind SQL injection - you won t see the result in response, but injected query will execute on background. If the query fails, it will be logged to Event log

  4. 1. Go to Contact Groups, create new group and go to Conditions. 2. Select 'Contact has value in field' macro. It allows us to insert arbitrary input before operator in where clause (e.g. WHERE <field> contains <value>). You can identify it by inserting `, recalculating group and then checking event log. 3. Final payload (change FirstName of the administrator account) 1=1; UPDATE CMS_User SET FirstName='Joe' WHERE UserID = 53-- Finish the WHERE clause of the original query with any True statement, e.g. 1=1 Add ; to finish first query Arbitrary query to drop table, dump data or anything Comment out everything else with --

  5. Event log user@localhost.local Pass.word1 Digital Channel Manager Users

  6. Users Roles Event log

  7. administrator Users

  8. Users email email queue

  9. Send us a message

  10. <img src=0 onerror=alert(1) /> Contact management

  11. http(s):// Forms application

  12. javascript:alert(document.cookie)

  13. file upload xml file Cafe

  14. /api/cmd allowedExtensions 3. Resend / edit change png to xml (/getmedia/.../payload.xml

  15. ../..

  16. ..\..\.

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#