Error-Based SQL Injection di Portal Berita Pemerintah kabupaten [REDACTED] via Parameter id_news
The id_news URL parameter was inserted into a SQL query without sanitisation, so a single quote broke the query and the site displayed a raw MariaDB error. An attacker could use those error messages to map the database structure and potentially extract sensitive data.
Published on icikiwirsol.medium.com
Bug Hunter
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
The target is a public service portal belonging to the government of a regency (kabupaten) whose name is redacted in the report. The URL ends in index.php, which suggests a PHP-based page. and serves news content through a component-style routing scheme: a com parameter selects the component and an id_news parameter selects the individual news item. The feature under test is therefore the news reader page, which normally takes a numeric identifier and renders the corresponding article.
The researcher, Primandito Adi Setiya, tested the portal on 14 November 2025 and published this write-up on 9 October 2026. The vulnerability class is error-based SQL injection in the id_news parameter, rated Critical in the summary. The report records the outcome as a silent fix: the issue was corrected without any confirmation or reply from the responsible party.
Setup
The report describes no accounts, roles, tooling or special preconditions. The only requirement to reproduce the finding is network access to the public news page and a browser or HTTP client capable of requesting a URL with a trailing single quote. No authentication is mentioned, and the injection is reached from the public-facing news component.
Finding it
While testing the news feature, the researcher observed that the value of id_news is passed into a database query without sanitisation. The reasoning given is straightforward: the parameter is concatenated into the SQL statement directly, with no escaping and no prepared statements. Because of that, a special character such as a single quote (') breaks the syntax of the query and triggers an error.
The second half of the finding is that the application does not hide that error. Raw database error messages from MariaDB are rendered to the user, which turns a syntax break into an information leak: the text of the error can be used to map the database structure, table names, and potentially to extract sensitive data.
Exploitation
Step 1: Identify the target
The researcher opened the news page at the following URL:
com=isi and id_news=290 are the values in the URL the researcher opened.
Step 2: Inject the payload (error-based test)
A single quote was appended to the end of the id_news value:
The quote is the payload. If the value is placed inside a quoted string literal in the SQL statement, the quote closes that literal early and leaves the rest of the statement syntactically invalid.

Step 3: Analyse the error
After the URL was requested, the application displayed a raw SQL error message from MariaDB:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''290'' at line 1
The error text includes the fragment near ''290'', showing the value reflected in the query. The database engine is identified as MariaDB, and the error is returned to the client..

Step 4: Verify the fix (post-fix)
After the report, the responsible party appears to have fixed the issue quietly. At the time of writing, requesting the same URL with the same payload no longer returns the SQL error. This verification was performed on 9 October 2026.
Root cause
The mistake is the classic one: user input from the id_news URL parameter is inserted into the SQL query by string concatenation, without escaping and without prepared statements. The report states this directly. Because the input is not separated from the query text, any character with meaning in SQL changes the structure of the statement, and a single quote is enough to produce a syntax error.
The existing defences did not stop it. There is no evidence in the report of input validation restricting id_news to digits, and no evidence of parameterised queries. On top of that, the application runs with database error display enabled in production, so the failure mode is verbose: instead of a generic error page, the user receives the raw MariaDB message. That display setting is what makes the injection error-based rather than blind.
Impact
The report lists four consequences, with hedges worth keeping:
- Information disclosure. Reading the database structure, including table and column names, through leaked error messages.
- Data exfiltration. Potentially extracting sensitive data such as administrator credentials, user data or other internal information.
- Data manipulation. If the database privileges are high enough, an attacker could modify or delete existing data.
- Authentication bypass. In some cases, SQL injection can be used to get past a login page.
The conditions matter: exfiltration and manipulation depend on what the injected queries can reach and on the privileges of the database account the application uses, and the authentication bypass is presented as a general possibility rather than something demonstrated on this target. What the report does demonstrate is the syntax error and the disclosure of the database engine.
Fix
The report does not describe the change that was made; it only records that the same payload no longer produces an SQL error as of 9 October 2026. The remediation it recommends consists of three steps:
- Use prepared statements. Always use parameterised queries so that SQL code and user input are kept separate.
- Validate input. Restrict the characters allowed in
id_news, for example to digits only, and reject suspicious input. - Disable error messages in production. Never show raw database errors to users. Redirect to a custom error page and record the details in internal logs only.
Variants to test
- Numeric context without quotes. If
id_newsis used unquoted, a value such as290followed by an arithmetic expression can change the result set. A positive result is a page that renders a different article or an error that reveals the query structure. - Other component parameters. The portal uses a
comparameter to select components. Test other components that take identifiers the same way, looking for the same raw MariaDB error text. - Union-based extraction. Once the column count is known, a
UNION SELECTin the same parameter can return data from other tables. A positive result is content from the database appearing in the page body. - Boolean and time-based confirmation. Where errors are suppressed, compare responses for true and false conditions, or measure response time for a deliberate delay. A consistent difference confirms the injection even without error output.
- Error display on other paths. Request a non-existent identifier or malformed value on other endpoints and check whether raw database errors appear. Any leaked query fragment is a finding in itself.
What happened, in plain words
A security researcher was looking at a public website run by a local government (a regency, or kabupaten, in Indonesia). The site has a news section, like many government portals: you click a headline and it shows you the article. Each article has a number, and the page asks the database for the article with that number.
The researcher found that the website took the number straight from the address bar and dropped it into the instruction it sends to its database, without checking it first. By adding one extra character, a single quote, to the address, he made that instruction malformed. The database complained, and the website showed the complaint to the visitor, word for word. That complaint revealed which database software is used and a piece of the instruction itself. That is enough to start learning how the database is built, and in the wrong hands it can lead to reading or changing data that should stay private.
The researcher reported it, the site was fixed quietly without a reply, and he later checked that the trick no longer works. This article walks through the same steps for someone who has never done security testing before. You only need a browser.
The target and the feature
The portal belongs to the government of a regency whose name is hidden in the report. The address ends in .php, which suggests the page is written in PHP, a common programming language for websites. The news section works with two values in the address:
compicks which part (component) of the site you want. Herecom=isimeans the news content.id_newspicks which article you want, by its number.
So the news reader page is the feature under test. Normally you give it a number and it shows the matching article. The researcher, Primandito Adi Setiya, tested the portal on 14 November 2025 and published this write-up on 9 October 2026. He classifies the problem as error-based SQL injection in the id_news parameter and rates it Critical. The outcome is recorded as a silent fix: the problem was corrected without any confirmation or reply from the responsible party.
What SQL injection means, from zero
A website that stores articles, users or orders almost always keeps them in a database: a program that holds data in tables and answers questions. The website asks questions in a small language called SQL. A typical question looks like "give me the article whose number is 290".
A safe website keeps the question and the visitor's input separate, the way a bank teller treats the amount you write on a slip as a number, not as an instruction to the teller. An unsafe website glues the input into the question as text. Then a visitor can type something that is not a number but a piece of SQL, and the database treats it as part of the question. That is SQL injection: the visitor's input changes the meaning of the database instruction.
Error-based means the website helps the attacker by showing the database's error message. The message often contains a fragment of the broken question, which leaks how the question is built.
Setup
The report describes no accounts, roles, tools or special conditions. To reproduce the finding you only need network access to the public news page and a browser (or any program that can request a web address). No login is mentioned, and the injection is reached from the public news page.
Finding it
While testing the news feature, the researcher noticed that the value of id_news is passed into a database query without being cleaned first. The reasoning is simple: the value is glued into the SQL statement directly, with no escaping (no marking of special characters so they lose their meaning) and no prepared statements (a technique that keeps the query and the input apart). Because of that, a special character such as a single quote (') breaks the query's grammar and causes an error.
The second half of the finding is that the application does not hide that error. Raw database error messages from MariaDB (a popular free database program) are shown to the visitor. That turns a grammar mistake into an information leak: the error text can be used to map the database structure and table names, and potentially to extract sensitive data.
Exploitation
Step 1: Identify the target
The researcher opened the news page at this address:
Line by line:
http://is the ordinary, unencrypted web protocol. Your browser uses it whenever an address starts this way.redacted.redactedkab.go.idis the site's host name. The report hides the real name;.go.idis the domain used by Indonesian government bodies./index.phpis the file the server runs.indexis the usual name for a site's main page, and.phpshows the page is written in PHP.?marks the start of the query string, the part of the address that carries values to the page.com=isitells the page which component to show: the news content.&separates one value from the next.id_news=290is the article number used in the request.
Why this step: you first need to see the page working normally. That gives you a baseline.
Step 2: Inject the payload (error-based test)
A single quote was added to the end of the id_news value:
Line by line:
- Everything up to
id_news=is the same as before. 290'is the new value: the number 290 followed by a single quote.- The quote is the payload, the piece of input designed to change the query.
Why this step: in SQL, text values are wrapped in single quotes, like '290'. If the website builds its question by gluing your value inside those quotes, your extra quote closes the text early. The rest of the question is then left dangling and the database cannot make sense of it. You are not trying to steal anything yet; you are testing whether your input reaches the database as code.

Step 3: Analyse the error
After the address was requested, the application displayed a raw SQL error message from MariaDB:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''290'' at line 1
Line by line:
You have an error in your SQL syntaxmeans the database could not parse the question. The grammar was wrong.check the manual that corresponds to your MariaDB server versionis standard wording that names the database program: MariaDB.near ''290''shows the text around the mistake, including the value that was sent.at line 1says the mistake is on the first line of the query.
Why this step matters: the error proves three things at once. Your input reaches the SQL statement unescaped. The database is MariaDB. And the error is sent back to the visitor. That last point is what makes this error-based rather than blind (blind means you get no error text and must infer the result from other behaviour).

Step 4: Verify the fix (post-fix)
After the report, the responsible party appears to have fixed the issue quietly. At the time of writing, requesting the same address with the same payload no longer returns the SQL error. This check was performed on 9 October 2026.
Why this step: a finding is only closed when you can show the old trick no longer works. Repeating the exact same request is the simplest fair test, because nothing else about your input has changed.
Root cause
The mistake is the classic one: the visitor's input from the id_news address parameter is inserted into the SQL query by gluing strings together, without escaping and without prepared statements. The report states this directly. Because the input is not separated from the query text, any character that has a meaning in SQL changes the structure of the question, and a single quote is enough to cause a grammar error.
The existing defences did not stop it. The report shows no sign of input validation restricting id_news to digits, and no sign of parameterised queries. On top of that, the application runs with database error display switched on in production, so the failure is loud: instead of a generic error page, the visitor receives the raw MariaDB message. That display setting is what makes the injection error-based rather than blind.
Impact
The report lists four consequences, with hedges worth keeping:
- Information disclosure. Reading the database structure, including table and column names, through leaked error messages.
- Data exfiltration. Potentially extracting sensitive data such as administrator credentials, user data or other internal information.
- Data manipulation. If the database privileges are high enough, an attacker could modify or delete existing data.
- Authentication bypass. In some cases, SQL injection can be used to get past a login page.
The conditions matter: exfiltration and manipulation depend on what the injected queries can reach and on the privileges of the database account the application uses, and the authentication bypass is presented as a general possibility rather than something demonstrated on this target. What the report does demonstrate is the grammar error and the disclosure of the database engine.
Fix
The report does not describe the change that was made; it only records that the same payload no longer produces an SQL error as of 9 October 2026. The remediation it recommends has three steps:
- Use prepared statements. Always use parameterised queries so that SQL code and user input are kept separate.
- Validate input. Restrict the characters allowed in
id_news, for example to digits only, and reject suspicious input. - Disable error messages in production. Never show raw database errors to users. Redirect to a custom error page and record the details in internal logs only.
Variants to test
- Numeric context without quotes. If
id_newsis used unquoted, a value such as290followed by an arithmetic expression can change the result set. A positive result is a page that renders a different article or an error that reveals the query structure. - Other component parameters. The portal uses a
comparameter to select components. Test other components that take identifiers the same way, looking for the same raw MariaDB error text. - Union-based extraction. Once the column count is known, a
UNION SELECTin the same parameter can return data from other tables. A positive result is content from the database appearing in the page body. - Boolean and time-based confirmation. Where errors are suppressed, compare responses for true and false conditions, or measure response time for a deliberate delay. A consistent difference confirms the injection even without error output.
- Error display on other paths. Request a non-existent identifier or malformed value on other endpoints and check whether raw database errors appear. Any leaked query fragment is a finding in itself.
Glossary
- API: a way for one program to ask another for data or actions, like a waiter taking your order to the kitchen.
- Authentication bypass: getting past a login page without valid credentials.
- Blind SQL injection: SQL injection where no error text is shown, so the attacker infers results from other behaviour.
- Component: a part of a website selected by a value in the address, here chosen with
com. - Concatenation: gluing pieces of text together into one string.
- Cookie: a small piece of data a website stores in your browser to remember you between requests.
- Database: a program that stores data in tables and answers questions about it.
- Error-based SQL injection: SQL injection where the database's error message is shown to the visitor and leaks information.
- Escaping: marking special characters in input so they lose their special meaning.
- Exfiltration: copying data out of a system without permission.
- HTTP: the ordinary, unencrypted protocol browsers use to fetch web pages.
- Information disclosure: revealing information that should have stayed private.
- MariaDB: a popular free database program, compatible with MySQL.
- Parameter: a named value in an address, such as
id_news. - Parameterised query (prepared statement): a database query where the code and the input are kept separate, so input cannot change the query's meaning.
- Payload: the piece of input designed to trigger a vulnerability.
- PHP: a programming language commonly used to build websites.
- Privileges: the permissions a database account has, such as reading or deleting data.
- Query: a question or instruction sent to a database in SQL.
- Query string: the part of an address after
?, carrying values to the page. - Silent fix: a vulnerability fixed without any confirmation or reply to the reporter.
- SQL: the language used to ask questions of a database.
- SQL injection: making a website's input change the meaning of its database query.
- Syntax error: a grammar mistake that stops a program from understanding an instruction.
- Token: a short piece of data, often secret, that proves who you are or lets a program act on your behalf.
- UNION SELECT: an SQL feature that combines the results of two queries, used to pull data from other tables.
- Validation: checking input against rules, such as allowing digits only.
- Vulnerability: a weakness in a system that can be used to make it behave in unintended ways.