Issue with SQLi and CSRF

255 views
Skip to first unread message

Yi SONG

unread,
Jun 15, 2021, 4:45:15 AM6/15/21
to OWASP ZAP User Group
Hi all,
I have scanned an application using ZAP GUI and find some issues that I am not very clear about it. The project is developed using sprint boot + vue 2.

1. SQL Injection
The result is as below. it is indicating PostgreSQL. I am using MySQL as database server. Should it be considered a vulnerability? 
-----------------------------------------------------------------------------------------------------------------------------------
High (Medium)Advanced SQL Injection - PostgreSQL > 8.1 AND time-based blind
Description

A SQL injection may be possible using the attached payload

URL
https://127.0.0.1/api/configs/11/data:search
Method
POST
Parameter
page
Attack
1') AND 5813=(SELECT 5813 FROM PG_SLEEP(5)) AND ('kQQK'='kQQK
Instances
1
Solution

Do not trust client side input, even if there is client side validation in place.

In general, type check all data on the server side.

If the application uses JDBC, use PreparedStatement or CallableStatement, with parameters passed by '?'

If the application uses ASP, use ADO Command Objects with strong type checking and parameterized queries.

If database Stored Procedures can be used, use them.

Do *not* concatenate strings into queries in the stored procedure, or use 'exec', 'exec immediate', or equivalent functionality!

Do not create dynamic SQL queries using simple string concatenation.

Escape all data received from the client.

Apply a 'whitelist' of allowed characters, or a 'blacklist' of disallowed characters in user input.

Apply the privilege of least privilege by using the least privileged database user possible.

In particular, avoid using the 'sa' or 'db-owner' database users. This does not eliminate SQL injection, but minimizes its impact.

Grant the minimum database access that is necessary for the application.


Other information

The query time is controllable using parameter value [1') AND 5813=(SELECT 5813 FROM PG_SLEEP(5)) AND ('kQQK'='kQQK], which caused the request to take [20 026] milliseconds, when the original unmodified query with value [1] took on average [20 001,667] milliseconds.

-----------------------------------------------------------------------------------------------------------------------------------

2. Anti CSRF
I have included 127.0.0.1 in the context. The URL which has the problem links to google.com. how should I understand it? is it a false positive or is it a bug in ZAP?

-----------------------------------------------------------------------------------------------------------------------------------
Low (Medium)Absence of Anti-CSRF Tokens
Description

No Anti-CSRF tokens were found in a HTML submission form.

A cross-site request forgery is an attack that involves forcing a victim to send an HTTP request to a target destination without their knowledge or intent in order to perform an action as the victim. The underlying cause is application functionality using predictable URL/form actions in a repeatable way. The nature of the attack is that CSRF exploits the trust that a web site has for a user. By contrast, cross-site scripting (XSS) exploits the trust that a user has for a web site. Like XSS, CSRF attacks are not necessarily cross-site, but they can be. Cross-site request forgery is also known as CSRF, XSRF, one-click attack, session riding, confused deputy, and sea surf.

CSRF attacks are effective in a number of situations, including:

* The victim has an active session on the target site.

* The victim is authenticated via HTTP auth on the target site.

* The victim is on the same local network as the target site.

CSRF has primarily been used to perform an action against a target site using the victim's privileges, but recent techniques have been discovered to disclose information by gaining access to the response. The risk of information disclosure is dramatically increased when the target site is vulnerable to XSS, because XSS can be used as a platform for CSRF, allowing the attack to operate within the bounds of the same-origin policy.



URL
https://www.google.com/search?q=go&rlz=1C1ONGR_frFR949FR949&oq=go&aqs=chrome..69i57.536j0j7&sourceid=chrome&ie=UTF-8
Method
GET
Evidence
<form class="tsf" action="/search" id="tsf" data-submitfalse="q" method="GET" name="f" role="search">
Instances
1
Solution

Phase: Architecture and Design

Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

For example, use anti-CSRF packages such as the OWASP CSRFGuard.

Phase: Implementation

Ensure that your application is free of cross-site scripting issues, because most CSRF defenses can be bypassed using attacker-controlled script.

Phase: Architecture and Design

Generate a unique nonce for each form, place the nonce into the form, and verify the nonce upon receipt of the form. Be sure that the nonce is not predictable (CWE-330).

Note that this can be bypassed using XSS.

Identify especially dangerous operations. When the user performs a dangerous operation, send a separate confirmation request to ensure that the user intended to perform that operation.

Note that this can be bypassed using XSS.

Use the ESAPI Session Management control.

This control includes a component for CSRF.

Do not use the GET method for any request that triggers a state change.

Phase: Implementation

Check the HTTP Referer header to see if the request originated from an expected page. This could break legitimate functionality, because users or proxies may have disabled sending the Referer for privacy reasons.


Other information

No known Anti-CSRF token [anticsrf, CSRFToken, __RequestVerificationToken, csrfmiddlewaretoken, authenticity_token, OWASP_CSRFTOKEN, anoncsrf, csrf_token, _csrf, _csrfSecret, __csrf_magic, CSRF] was found in the following HTML form: [Form 1: "q" "rlz" "ei" "iflsig" ].

-----------------------------------------------------------------------------------------------------------------------------------

Thank you in advance!

best regards,

Yi SONG

kingthorin+owaspzap

unread,
Jun 15, 2021, 9:28:09 AM6/15/21
to OWASP ZAP User Group
For the first one you'd have to test further to validate.

For the second one, it's a true positive but you're unlikely to be able to get Google to change anything so you can treat it as you see fit. It seems to be a simple search and it isn't using your resources so it's not really an issue for you.
Reply all
Reply to author
Forward
0 new messages