Resolve vulnerability VDP-3315

Aperta
#427 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, postgresql, python

Direzione di ricerca

Read the YANG-to-SQL Jinja2 template, especially line 113, and compare it with the filtered description at line 37. Trace where the generated SQL reaches session.execute() and check the related issue #426 for context. The fix is complete when the revision description cannot inject SQL and the relevant upload path is covered by verification.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug CRIT-2

In accordance with the findings from the NASA Vulnerability Disclosure Program, a summary of VDP 3315 can be found below, as well as suggestions for remediation. For more information like how to recreate the issue, contact @mfarina1 for the full PDF description. Note that this issue should be remediated as soon as possible and that it also relates to #426.

Researcher Description
The ANMS ADM upload endpoint (POST /adms/) accepts YANG files and generates SQL from them
using a Jinja2 template. One field · the revision description · is missing the sql_string escape filter that
every other description field uses. The generated SQL is executed raw via session.execute() with no
parameterization. Combined with the fact that port 5555 has no authentication (see CVE-2026-71289 for
the related auth issue on port 8089), a single unauthenticated HTTP request achieves arbitrary SQL
execution on PostgreSQL.

The Jinja2 template that converts YANG into SQL has a sql_string filter for escaping quotes. It's
applied on every description field except one:

  • Line 37 (safe): {%- set description = obj.description | sql_string %}
  • Line 113 (vulnerable): {{"'"~adm.revisions[-1].description~"'"}} · raw string concatenation, no filter

The generated SQL is then passed directly to SQLAlchemy's session.execute(queries) as a raw string · no
parameterized queries.

This vulnerability was reproduced locally using the official anms docker from
https://github.com/NASA-AMMOS/anms.git

Remediation Advice
Ensure that proper server-side input validation is performed on all sources of user input. Various
protections should be implemented using the following in order of effectiveness:

  1. Errors: Ensure that SQL errors are turned off and not reflected back to a user when an error occurs as
    to not expose valuable information to an attacker.
  2. Parameterize Queries: Ensure that when a user·s input is added to a backend SQL query, it is not string
    appended but placed into the specific SQL parameter. The method to perform this varies from language
    to language.
  3. Server-Side Input Length: Limit the length of each field depending on its type. For example, a name
    should be less than 16 characters long, and an ID should be less than 5 characters long.
  4. Whitelist: Create character ranges (ie. Numeric, alpha, alphanumeric, alphanumeric with specific
    characters) and ensure that each input is restricted to the minimum length whitelist necessary.
  5. Blacklist: Disallow common injection characters such as "<>\/?*()&, SQL and SCRIPT
    commands such as SELECT, INSERT, UPDATE, DROP, and SCRIPT, newlines %0A,
    carriage returns %0D, null characters %00 and unnecessary or bad encoding schemas (malformed
    ASCII, UTF-7, UTF-8, UTF-16, Unicode, etc.).
  6. Logging and Web Specific IDS/IPS (Intrusion Detection/Prevention System): Ensure that proper
    logging is taking place and is being reviewed, and any malicious traffic which generates an alert is
    promptly throttled and eventually blacklisted.
Lingua principale
JavaScript
Stelle
3
Fork
2
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NASA-AMMOS/anms

Tutte le issue di NASA-AMMOS/anms

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.