security: block NQ Vault path traversal on decrypted file writes#669
Conversation
abrignoni
left a comment
There was a problem hiding this comment.
Code looks good. Sanitizes names and path.
|
@mobasi-team @abrignoni looks good to me as well, I'm wondering if the sanitization should be utilized as a function for other parsers too, something we can look at |
|
We found these as being places where there's a risk of file path traversal, but it's much harder for an attacker to take advantage of these.
Harder to exploit, but present:
|
Commit
0cafd8f- security: block NQ Vault path traversal on decrypted file writesSecurity issue
NQ_Vault.pyused attacker-controlledfile_name_fromfrom DB directly in:open(join(report_folder, decrypted_file_name), 'wb')This allowed traversal values like
../../../outside_written.binto write outside the report output tree.Vulnerability verification
Confirmed as real in a controlled local PoC on pre-fix code:
old_filename = '../../../outside_written.bin'outside_exists: Trueis_outside_report: TrueFix implemented
NQ_Vault.py:_sanitize_output_filename(...)_build_safe_output_path(...)report_folderRegression tests added
admin/test/scripts/test_nq_vault_path_security.pyQA run
python3 admin/test/scripts/test_nq_vault_path_security.pypython3 -m py_compile scripts/artifacts/NQ_Vault.py admin/test/scripts/test_nq_vault_path_security.py