Skip to content

Fix: quote NVT OID in SQL statements#2991

Open
imurd wants to merge 4 commits into
greenbone:mainfrom
imurd:fix/quote-nvt-oid-sql
Open

Fix: quote NVT OID in SQL statements#2991
imurd wants to merge 4 commits into
greenbone:mainfrom
imurd:fix/quote-nvt-oid-sql

Conversation

@imurd

@imurd imurd commented Jun 25, 2026

Copy link
Copy Markdown

What

Wrap NVT OIDs in sql_quote() before interpolating them into SQL in
insert_nvt(), insert_vt_severities(), insert_vt_refs() and the OSP /
openvasd preference deletes.

Why

The OID comes straight from the feed/scanner (nvti_oid) and was
concatenated into the SQL unquoted, while every other string in the same
statements already goes through sql_quote(). An OID containing a single
quote breaks the generated statement, so the NVT update/rebuild fails,
and it allows SQL injection from feed data.

Tests

Added a regression test covering OID quoting.

References

Checklist

  • Tests

NVT OIDs from the feed were interpolated into SQL unquoted, unlike the
other fields in the same statements. An OID with a single quote breaks
the statement and allows SQL injection, failing NVT update/rebuild.
Pass nvti_oid() through sql_quote() everywhere it is used in SQL.
@imurd imurd requested review from a team as code owners June 25, 2026 15:31
@greenbonebot greenbonebot enabled auto-merge (rebase) June 25, 2026 15:31
auto-merge was automatically disabled June 25, 2026 15:34

Head branch was pushed to by a user without write access

@greenbonebot greenbonebot enabled auto-merge (rebase) June 25, 2026 15:34
@bjoernricks

Copy link
Copy Markdown
Contributor

Hi, without a description why this is necessary and what actually is broken without your changes this PR can't be merged. Please add the PR description and update your commit message to add why the change has been done (for example with git rebase -i)

auto-merge was automatically disabled June 26, 2026 08:37

Head branch was pushed to by a user without write access

@imurd imurd force-pushed the fix/quote-nvt-oid-sql branch from 3a7eac7 to 022fae4 Compare June 26, 2026 08:37
@greenbonebot greenbonebot enabled auto-merge (rebase) June 26, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants