Fix: quote NVT OID in SQL statements#2991
Open
imurd wants to merge 4 commits into
Open
Conversation
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.
auto-merge was automatically disabled
June 25, 2026 15:34
Head branch was pushed to by a user without write access
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 |
auto-merge was automatically disabled
June 26, 2026 08:37
Head branch was pushed to by a user without write access
3a7eac7 to
022fae4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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