Fossil Forum

Fossil detected an (unsuccessful) SQL injection attack
Login

Fossil detected an (unsuccessful) SQL injection attack

Fossil detected an (unsuccessful) SQL injection attack

(1) By anonymous on 2024-03-16 13:03:22 [source]

http://localhost:8080/info/4b7f23f9851d8494 and any other link to a checkin / commit returns the following:

Begone, Knave!

This page was generated because Fossil detected an (unsuccessful) SQL injection attack or other nefarious content in your HTTP request.

If you believe you are innocent and have reached this page in error, contact the Fossil developers on the Fossil-SCM Forum. Type "fossil-scm forum" into any search engine to locate the Fossil-SCM Forum. This page was generated in about 0.003s by Fossil 2.23 [47362306a7] 2023-11-01 18:56:47

This did not happen with 2.22. What to do? Is this known?

(2) By Stephan Beal (stephan) on 2024-03-16 13:27:17 in reply to 1 [link] [source]

... and any other link to a checkin / commit returns the following:

i strongly suspect that you are a victim of over-aggressive browser caching (they are often overzealous about caching localhost pages, a problem i frequently run into). That message will only show up if certain URL parameters contain what appears to be SQL, and the URL you have shown us does not have any such parameters.

This did not happen with 2.22. What to do? Is this known?

My first suggestion is to enable your browser's dev tools (F12 on most browsers), switch to the Network tab, and click the "disable cache" checkbox. With the dev tools still open, visit that URL, and my suspicion is that the error will magically disappear.

Alternately, with the error page on the screen, tap Ctrl-Reload (or whatever button combination in your browser bypasses the cache) and see if it goes away. If it does not go away, please make a copy of the repository in question available to us for debugging, and with one or two of the URLs which are giving you problems (including any arguments you may be passing to them, as those are what will trigger the error you reported).

(3) By anonymous on 2024-03-16 13:41:11 in reply to 2 [link] [source]

Found the culprit, not sure why fossil checks cookies (these are not relevant for SQLi):

possible hack attempt - 418 response on "optanonconsent" ... optanonconsent = isGpcEnabled=0&datestamp=Thu Aug 24 2023 09:16:08 GMT+0200 (Mitteleuropäische Sommerzeit)&version=2...

(4) By Richard Hipp (drh) on 2024-03-16 15:54:06 in reply to 3 [link] [source]

cookies ... are not relevant for SQLi

I beg to differ. You can have SQL injection on a cookie just as easily as you can on a query parameter.

I also see SQLi attempts on the "Referer" and the "User-Agent" strings in the HTTP header.

(6) By anonymous on 2024-03-16 17:12:54 in reply to 4 [link] [source]

Referer and Useragent are used for that, because logging solutions log the content of these fields in most cases (think about page visitor statistics per browser and referer).

Still, cookies are normally not passed as input to SQL queries. I've never seen that in over 13 years of webdevelopment. Sure, it's userinput, but in this case, does fossil really store cookie values (they can be a maximum of 4093 bytes big) in the database or use them as input? If so, that should not be a risk when prepared statements are used.

(8) By Stephan Beal (stephan) on 2024-03-16 17:26:53 in reply to 6 [link] [source]

Sure, it's userinput, but in this case, does fossil really store cookie values (they can be a maximum of 4093 bytes big) in the database or use them as input?

A malicious user could stuff data into their cookies in an attempt to get fossil to interpret that a GET/POST state for specific pages, and that would harmlessly work in many contexts, but...

If so, that should not be a risk when prepared statements are used.

Most definitely not. Raw user inputs are never used in SQL statements in fossil, with the exception of a couple of admin-only features such as ticket configuration. Any user-provided inputs for queries are of course handled as bound parameters, not SQL text.

(5) By Stephan Beal (stephan) on 2024-03-16 16:40:22 in reply to 3 [link] [source]

Found the culprit

Aha, sneaky.

not sure why fossil checks cookies

Internally Fossil consolidates GET, POST, and cookie arguments and does not distinguish between them after their initial parsing.

(7) By anonymous on 2024-03-16 17:14:27 in reply to 5 [link] [source]

Ah, good to know. I would have expect, that cookies are not handled like get and post requests (because for that cookies are not used, only for storing data or information states).