Resolve vulnerability VDP-3315

Open
#427 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, postgresql, python

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
JavaScript
Stars
3
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NASA-AMMOS/anms

All issues in NASA-AMMOS/anms

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.