Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B411 error can't be resolved by the suggested change #1082

Open
kajinamit opened this issue Dec 21, 2023 · 0 comments
Open

B411 error can't be resolved by the suggested change #1082

kajinamit opened this issue Dec 21, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@kajinamit
Copy link
Contributor

kajinamit commented Dec 21, 2023

Describe the bug

We recently faced the following bandit error in oslo.serialization project. It seems bandit 1.7.6 contains the commit 3260f13 and now it reject importing xmlrpc.

>> Issue: [B411:blacklist] Using client to parse untrusted XML data is known to be vulnerable to XML attacks. Use defused.xmlrpc.monkey_patch() function to monkey-patch xmlrpclib and mitigate XML vulnerabilities.
   Severity: High   Confidence: High
   CWE: CWE-20 (https://cwe.mitre.org/data/definitions/20.html)
   More Info: https://bandit.readthedocs.io/en/1.7.6/blacklists/blacklist_imports.html#b411-import-xmlrpclib
   Location: oslo_serialization/jsonutils.py:40:0
38	import json
39	import uuid
40	from xmlrpc import client as xmlrpclib
41
42	from oslo_utils import encodeutils

However bandit still detects the error even if we add the monkey_patch as suggested by the message.

Reproduction steps

  1. Run bandit with the code
from xmlrpc import client as xmlrpclib
  1. ZB411 error is detected
  2. Update the code to include the suggested change
import defusedxml.xmlrpc
frm xmlrpc import client as xmlrpclib

defusedxml.xmlrpc.monkey_patch()
  1. Run bandit again and it still detects the same error

Expected behavior

The execution at step 4 does not detect the error

Bandit version

1.7.6 (Default)

Python version

3.11

Additional context

No response

@kajinamit kajinamit added the bug Something isn't working label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant