Redaxscript — 3 vulnerability checks

noctis ships 3 vulnerability checks for Redaxscript, covering 3 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Redaxscript 0.3.2 password reset SQL injection

CVECVE-2011-5313
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/redaxscript/CVE-2011-5313.yaml

Redaxscript 0.3.2 passes the id and password request parameters of its password reset page (includes/password.php) into an SQL query without escaping them, so an unauthenticated visitor can inject SQL into the CMS database.

Under the web root and /redaxscript, this check requests the password reset page with a random token as a control, then with a single quote appended to the token in the id parameter and then in the password parameter, and finally with two quotes. The vulnerability is reported when the single-quote request prints a MySQL syntax error while the control and the balanced two-quote request print none. Nothing is written and no data is read from the database.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{adir}}/index.php?{{q.ctl}}
  3. HTTP(S) request GET {{adir}}/index.php?{{q.id1}}
  4. HTTP(S) request GET {{adir}}/index.php?{{q.id2}}
  5. HTTP(S) request GET {{adir}}/index.php?{{q.pw1}}
  6. HTTP(S) request GET {{adir}}/index.php?{{q.pw2}}
  7. Parses / computes the next value with a Rhai script
  8. Checks res.ok for ^true$ → finding QoD 75: Redaxscript password reset SQL injection (CVE-2011-5313)

References:

Feed source — tests/vulnerabilities/redaxscript/CVE-2011-5313.yaml
# Redaxscript 0.3.2 — includes/password.php id/password SQL injection (CVE-2011-5313)
#
# The password reset handler (includes/password.php, reached with p=password_reset)
# builds its query from the id and password request parameters without escaping them,
# so a lone quote breaks the statement and the page prints MySQL's syntax error.
#
# Detection (QoD 75), per candidate install dir (web root, /redaxscript), on each of the
# two vulnerable parameters in turn (id, then password):
#   1. p=password_reset with a random token (control) has no SQL error.
#   2. <param>=<token>' (one quote) answers with a MySQL syntax error.
#   3. <param>=<token>'' (balanced quotes) answers with no SQL error: the page is not
#      simply printing an error for any quote character.
# Read-only: the payloads are quote characters; nothing is written or read from the DB.
#
# Better than the source NVT: that one only checks the path disclosure of CVE-2011-5314;
# the SQL injection named in its advisory is proven here behaviourally.
# NVD CVSS v3.x for this CVE is 7.5.
#
# Source: OpenVAS/Greenbone NVT 2011/gb_redaxscript_path_disc_n_sql_inj_vuln.nasl
# (GPL-2.0-only). The upstream source of 0.3.2 was not reachable when this feed was
# written: the request shape follows the NVD/advisory text (password_reset, id/password).
uid: a59f552f-3dea-49ef-8cda-b02e55a5df69
name: "Redaxscript 0.3.2 password reset SQL injection (CVE-2011-5313)"
description: |
  Redaxscript 0.3.2 passes the id and password request parameters of its password reset
  page (includes/password.php) into an SQL query without escaping them, so an
  unauthenticated visitor can inject SQL into the CMS database.

  Under the web root and /redaxscript, this check requests the password reset page with a
  random token as a control, then with a single quote appended to the token in the id
  parameter and then in the password parameter, and finally with two quotes. The
  vulnerability is reported when the single-quote request prints a MySQL syntax error
  while the control and the balanced two-quote request print none. Nothing is written
  and no data is read from the database.
cves: [CVE-2011-5313]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [redaxscript, php, sqli, error-based]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-5313"

steps:
  - id: gen
    action: script
    code: |
      let t = "nc" + rand_hex(5);
      #{ ctl: "p=password_reset&id=" + t + "&password=" + t,
         id1: "p=password_reset&id=" + t + "%27&password=" + t,
         id2: "p=password_reset&id=" + t + "%27%27&password=" + t,
         pw1: "p=password_reset&id=" + t + "&password=" + t + "%27",
         pw2: "p=password_reset&id=" + t + "&password=" + t + "%27%27" }
    store_as: q

  # A loop: step runs together with every following non-loop step once per directory, so
  # the init steps below reset all stored results at the start of each iteration.
  - id: init-ctl
    action: set_var
    var_name: ctl_resp
    var_value: {status: 0, body: null}
    loop:
      over: ["", "/redaxscript"]
      var: adir

  - id: init-id1
    action: set_var
    var_name: id1_resp
    var_value: {status: 0, body: null}

  - id: init-id2
    action: set_var
    var_name: id2_resp
    var_value: {status: 0, body: null}

  - id: init-pw1
    action: set_var
    var_name: pw1_resp
    var_value: {status: 0, body: null}

  - id: init-pw2
    action: set_var
    var_name: pw2_resp
    var_value: {status: 0, body: null}

  - id: control
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.ctl}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: ctl_resp

  - id: inject-id1
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.id1}}"
    condition: 'ctl_resp.status == 200 && type_of(ctl_resp.body) == "string" && !ereg("(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)", ctl_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: id1_resp

  - id: inject-id2
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.id2}}"
    condition: 'id1_resp.status >= 200 && id1_resp.status < 500 && type_of(id1_resp.body) == "string" && ereg("error in your SQL syntax", id1_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: id2_resp

  - id: inject-pw1
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.pw1}}"
    condition: 'ctl_resp.status == 200 && type_of(ctl_resp.body) == "string" && !ereg("(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)", ctl_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: pw1_resp

  - id: inject-pw2
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.pw2}}"
    condition: 'pw1_resp.status >= 200 && pw1_resp.status < 500 && type_of(pw1_resp.body) == "string" && ereg("error in your SQL syntax", pw1_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: pw2_resp

  - id: check
    action: script
    code: |
      let c = if type_of(ctl_resp.body) == "string" { ctl_resp.body } else { "" };
      let a1 = if type_of(id1_resp.body) == "string" { id1_resp.body } else { "" };
      let a2 = if type_of(id2_resp.body) == "string" { id2_resp.body } else { "" };
      let b1 = if type_of(pw1_resp.body) == "string" { pw1_resp.body } else { "" };
      let b2 = if type_of(pw2_resp.body) == "string" { pw2_resp.body } else { "" };
      let bad = "(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)";
      let ok_ctl = ctl_resp.status == 200 && !ereg(bad, c);
      let id_ok = ok_ctl && id2_resp.status == 200 && ereg("error in your SQL syntax", a1) && !ereg(bad, a2);
      let pw_ok = ok_ctl && pw2_resp.status == 200 && ereg("error in your SQL syntax", b1) && !ereg(bad, b2);
      #{ ok: id_ok || pw_ok, param: if id_ok && pw_ok { "id and password" } else if id_ok { "id" } else { "password" } }
    store_as: res

  - id: report
    action: match
    source: res.ok
    pattern: "^true$"
    condition: "res.ok"
    on_match:
      finding:
        title: "Redaxscript password reset SQL injection (CVE-2011-5313)"
        description: "A single quote appended to the id or password parameter of Redaxscript's password reset page made it print a MySQL syntax error, while the same request without the quote and with a balanced pair of quotes printed none: the value reaches an SQL statement unescaped, so an unauthenticated attacker can run arbitrary SQL against the CMS database."
        remediation: "Upgrade Redaxscript to a release later than 0.3.2, which escapes these parameters."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{adir}}/index.php?p=password_reset: parameter {{res.param}} with one quote answers with an SQL syntax error, the control and the two-quote request answer without one"
      stop: true

Redaxscript 2.2.0 search_terms SQL injection

CVECVE-2015-1518
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionset_var, tcp_connect, script, match · highest QoD 75
Feedtests/vulnerabilities/redaxscript/CVE-2015-1518.yaml

Redaxscript 2.2.0 passes the search_terms field of its search form into an SQL query without escaping it, so an unauthenticated visitor can inject SQL into the CMS database.

Under the web root and /redaxscript, this check loads the home page to obtain the session cookie and the form token, then submits the search with the term "%')and(N=N)#" twice and "%')and(N=M)#" twice, with random numbers. The vulnerability is reported when the true conditions show search results and the false ones show the "Something went wrong" message. Nothing is written and no data is read from the database.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET {{adir}}/ HTTP/1.0
  2. Parses / computes the next value with a Rhai script
  3. Raw TCP (TLS on HTTPS), sent verbatim: POST {{adir}}/ HTTP/1.0
  4. Raw TCP (TLS on HTTPS), sent verbatim: POST {{adir}}/ HTTP/1.0
  5. Raw TCP (TLS on HTTPS), sent verbatim: POST {{adir}}/ HTTP/1.0
  6. Raw TCP (TLS on HTTPS), sent verbatim: POST {{adir}}/ HTTP/1.0
  7. Parses / computes the next value with a Rhai script
  8. Checks v.hit for ^true$ → finding QoD 75: Redaxscript search_terms SQL injection (CVE-2015-1518)

References:

Feed source — tests/vulnerabilities/redaxscript/CVE-2015-1518.yaml
# Redaxscript 2.2.0 — includes/search.php search_terms SQL injection (CVE-2015-1518)
#
# The search handler (search_post) puts the search_terms value into a LIKE clause without
# escaping it, so "%')and(A=B)#" closes the string and the parenthesis and appends a
# condition of the attacker's choosing: a true condition lists the matching content, a
# false one finds nothing and the page prints its "Something went wrong" box.
#
# Detection (QoD 75), per candidate install dir (web root, /redaxscript):
#   1. GET the home page over a raw socket: the search form's hidden token, and every
#      Set-Cookie of the reply (the app sets PHPSESSID several times; the last one counts).
#   2. POST the search with two true conditions (random N: and(N=N)) and two false ones
#      (and(N=M)); the injection is reported only when both true ones answer without the
#      error box and both false ones with it. A site that escapes the term treats the
#      payload as a literal search (no results, error box every time), a site that always
#      lists results never shows the box: neither gives a differential.
# Read-only: the conditions compare two random numbers; nothing is read from the database.
#
# Better than the source NVT: it needed the true request to lack the error box and the
# false one to show it once; this feed repeats the pair with fresh numbers, so a page
# that changes for another reason does not count.
# NVD publishes no CVSS v3.x score for this CVE; 7.5 is the base score listed in the backlog entry.
#
# Source: OpenVAS/Greenbone NVT 2015/gb_redaxscript_sql_inj_vuln.nasl (GPL-2.0-only).
uid: 7bf67c86-9f62-4c3b-9fc6-18cbc14fb1cf
name: "Redaxscript 2.2.0 search_terms SQL injection (CVE-2015-1518)"
description: |
  Redaxscript 2.2.0 passes the search_terms field of its search form into an SQL query
  without escaping it, so an unauthenticated visitor can inject SQL into the CMS database.

  Under the web root and /redaxscript, this check loads the home page to obtain the
  session cookie and the form token, then submits the search with the term
  "%')and(N=N)#" twice and "%')and(N=M)#" twice, with random numbers. The vulnerability
  is reported when the true conditions show search results and the false ones show the
  "Something went wrong" message. Nothing is written and no data is read from the database.
cves: [CVE-2015-1518]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [redaxscript, php, sqli, boolean]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2015-1518"

steps:
  - id: init-home
    action: set_var
    var_name: home
    var_value: {connected: false, banner: null}
    loop:
      over: ["", "/redaxscript"]
      var: adir

  - id: init-t1
    action: set_var
    var_name: r_t1
    var_value: {connected: false, banner: null}

  - id: init-f1
    action: set_var
    var_name: r_f1
    var_value: {connected: false, banner: null}

  - id: init-t2
    action: set_var
    var_name: r_t2
    var_value: {connected: false, banner: null}

  - id: init-f2
    action: set_var
    var_name: r_f2
    var_value: {connected: false, banner: null}

  - id: home
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{adir}}/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\n\r\n"
    store_as: home

  - id: prep
    action: script
    code: |
      let out = #{ ok: false, cookie: "", t1: "", f1: "", t2: "", f2: "", l_t1: 0, l_f1: 0, l_t2: 0, l_f2: 0 };
      if type_of(home.banner) == "string" && ereg("^HTTP/1\\.[01] 200 ", home.banner) {
        let tok = eregmatch("token\" value=\"([0-9a-z]+)\"", home.banner);
        let jar = #{};
        let cut = stridx(home.banner, "\r\n\r\n");
        let head = if cut >= 0 { substr(home.banner, 0, cut) } else { "" };
        for raw in split(head, "\n") {
          let c = eregmatch("^set-cookie:[ \\t]*([A-Za-z0-9_.-]+)=([^;\\r]*)", raw, true);
          if c.len() < 3 || c[2] == "" { continue; }
          jar[c[1]] = c[2];
        }
        for k in jar.keys() {
          if out.cookie != "" { out.cookie += "; "; }
          out.cookie += k + "=" + jar[k];
        }
        if tok.len() > 1 && ereg("PHPSESSID=", out.cookie) {
          let n1 = rand_int(10, 89);
          let n2 = rand_int(10, 89);
          let m1 = n1 + rand_int(1, 8);
          let m2 = n2 + rand_int(1, 8);
          let pre = "search_terms=%25%27%29and%28";
          let post = "%29%23&search_post=&token=" + tok[1] + "&search_post=Search";
          out.t1 = pre + n1 + "%3D" + n1 + post;
          out.f1 = pre + n1 + "%3D" + m1 + post;
          out.t2 = pre + n2 + "%3D" + n2 + post;
          out.f2 = pre + n2 + "%3D" + m2 + post;
          out.l_t1 = strlen(out.t1);
          out.l_f1 = strlen(out.f1);
          out.l_t2 = strlen(out.t2);
          out.l_f2 = strlen(out.f2);
          out.ok = true;
        }
      }
      out
    store_as: p

  - id: post-t1
    action: tcp_connect
    port: "{{port}}"
    condition: "p.ok == true"
    send: "POST {{adir}}/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nCookie: {{p.cookie}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {{p.l_t1}}\r\n\r\n{{p.t1}}"
    store_as: r_t1

  - id: post-f1
    action: tcp_connect
    port: "{{port}}"
    condition: "p.ok == true"
    send: "POST {{adir}}/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nCookie: {{p.cookie}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {{p.l_f1}}\r\n\r\n{{p.f1}}"
    store_as: r_f1

  - id: post-t2
    action: tcp_connect
    port: "{{port}}"
    condition: "p.ok == true"
    send: "POST {{adir}}/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nCookie: {{p.cookie}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {{p.l_t2}}\r\n\r\n{{p.t2}}"
    store_as: r_t2

  - id: post-f2
    action: tcp_connect
    port: "{{port}}"
    condition: "p.ok == true"
    send: "POST {{adir}}/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nCookie: {{p.cookie}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {{p.l_f2}}\r\n\r\n{{p.f2}}"
    store_as: r_f2

  - id: verdict
    action: script
    code: |
      let err = ">Something went wrong<";
      let hit = false;
      if p.ok == true {
        let rs = [r_t1, r_f1, r_t2, r_f2];
        let all200 = true;
        for r in rs {
          if type_of(r.banner) != "string" || !ereg("^HTTP/1\\.[01] 200 ", r.banner) { all200 = false; }
        }
        if all200 {
          hit = stridx(r_t1.banner, err) < 0 && stridx(r_t2.banner, err) < 0
            && stridx(r_f1.banner, err) >= 0 && stridx(r_f2.banner, err) >= 0;
        }
      }
      #{ hit: hit }
    store_as: v

  - id: report
    action: match
    source: v.hit
    pattern: "^true$"
    condition: "v.hit == true"
    on_match:
      finding:
        title: "Redaxscript search_terms SQL injection (CVE-2015-1518)"
        description: "Redaxscript's search form accepted the term %')and(N=N)# and listed results, while %')and(N=M)# with two different numbers listed none and printed the error message, twice with fresh random numbers: the term reaches an SQL statement unescaped, so an unauthenticated attacker can run arbitrary SQL against the CMS database."
        remediation: "Upgrade Redaxscript to 2.3.0 or later, which escapes the search terms."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{adir}}/ search form: and(N=N) conditions list results, and(N=M) conditions answer with the error message (two random pairs)"
      stop: true

Redaxscript 0.3.2 templates/default/index.php path disclosure

CVECVE-2011-5314
Severitymedium · CVSS 5.0
Categoryexposure — Exposure
Serviceshttp, https
Detectionset_var, http_request, script, match · highest QoD 75
Feedtests/vulnerabilities/redaxscript/CVE-2011-5314.yaml

Redaxscript 0.3.2 lets an anonymous visitor request templates/default/index.php directly. The file depends on functions that only exist when the CMS includes it, so PHP answers with a fatal error that reveals the absolute path of the script on the server.

This check requests that file under the web root and /redaxscript and reports the finding when the response is an HTTP 200 carrying a PHP "Fatal error ... Call to undefined function" message that names templates/default/index.php. Only a single GET is sent; nothing is written to the server.

How noctis detects it

  1. HTTP(S) request GET {{adir}}/templates/default/index.php
  2. Parses / computes the next value with a Rhai script
  3. Checks res.ok for ^true$ → finding QoD 75: Redaxscript templates/default/index.php path disclosure (CVE-2011-5314)

References:

Feed source — tests/vulnerabilities/redaxscript/CVE-2011-5314.yaml
# Redaxscript 0.3.2 — templates/default/index.php full path disclosure (CVE-2011-5314)
#
# The default template file is meant to be included by the CMS; requested directly it
# calls functions that are not defined and PHP prints a fatal error that contains the
# script's absolute filesystem path ("<b>Fatal error</b>: Call to undefined function ...
# in <b>/var/www/.../templates/default/index.php</b>").
#
# Detection (QoD 75), per candidate install dir (web root, /redaxscript):
#   GET <dir>/templates/default/index.php answers 200 with both "Fatal error" and
#   "Call to undefined function", and the reported file is that template.
# Read-only: one plain GET.
#
# NVD scores this CVE (v3.x) at 5.0 (v2 5.0).
#
# Source: OpenVAS/Greenbone NVT 2011/gb_redaxscript_path_disc_n_sql_inj_vuln.nasl
# (GPL-2.0-only). The NVT's SQL injection half is covered by CVE-2011-5313.
uid: 07f2abcb-f2f1-4a3a-950b-739dab534e3c
name: "Redaxscript 0.3.2 templates/default/index.php path disclosure (CVE-2011-5314)"
description: |
  Redaxscript 0.3.2 lets an anonymous visitor request templates/default/index.php
  directly. The file depends on functions that only exist when the CMS includes it, so
  PHP answers with a fatal error that reveals the absolute path of the script on the
  server.

  This check requests that file under the web root and /redaxscript and reports the
  finding when the response is an HTTP 200 carrying a PHP "Fatal error ... Call to
  undefined function" message that names templates/default/index.php. Only a single GET
  is sent; nothing is written to the server.
cves: [CVE-2011-5314]
cvss: 5.0
severity: medium
category: exposure
confidence_base: 0.30
tags: [redaxscript, php, path-disclosure, information-disclosure]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-5314"

steps:
  - id: init-resp
    action: set_var
    var_name: resp
    var_value: {status: 0, body: null}
    loop:
      over: ["", "/redaxscript"]
      var: adir

  - id: probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/templates/default/index.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: resp

  - id: check
    action: script
    code: |
      let b = if type_of(resp.body) == "string" { resp.body } else { "" };
      let m = eregmatch("(?s)Call to undefined function.{0,200}? in (?:<b>)?([^<\n]*templates/default/index\\.php)", b);
      let ok = resp.status == 200
        && ereg(">Fatal error<|Fatal error:", b)
        && ereg("Call to undefined function", b)
        && m.len() > 1;
      #{ ok: ok, path: if m.len() > 1 { m[1] } else { "" } }
    store_as: res

  - id: report
    action: match
    source: res.ok
    pattern: "^true$"
    condition: "res.ok"
    on_match:
      finding:
        title: "Redaxscript templates/default/index.php path disclosure (CVE-2011-5314)"
        description: "Requesting templates/default/index.php directly made Redaxscript's PHP print a fatal error (call to an undefined function) that discloses the absolute path of the script on the server, which helps an attacker plan further attacks."
        remediation: "Upgrade Redaxscript to a release later than 0.3.2, deny direct access to the templates directory in the web server configuration, and turn off display_errors in production."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{adir}}/templates/default/index.php: PHP fatal error disclosing the script path: {{res.path}}"
      stop: true

View these feeds on GitHub