PyCQA / PyCQA/bandit

xml.sax.saxutils.escape and quoteattr incorrectly flagged as insecure

Open
#452 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
8.3k
Forks
835
Avg merge
5d 3h
Merged PRs (30d)
1

Description

from xml.sax.saxutils import escape
from xml.sax.saxutils import quoteattr

Are flagged as Severity: Low Confidence: High. Instructions are to use the equivalent defusedxml package.

  1. I do not believe these imports to be insecure as they are simple text substitutions.
  2. There is no defusedxml equivalent.

Expected behavior
Do not mark escape and quoteattr as vulnerable.

Bandit version

bandit 1.5.1
  python version = 3.6.3 (default, Apr 26 2018, 13:16:02) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]

Contributor guide

Open the contributing guide

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.

Research direction

Start by locating the Bandit check that flags imports of xml.sax.saxutils.escape and quoteattr. Reproduce the report with the minimal imports shown, then confirm that neither import is marked vulnerable and add or update coverage if the relevant check has tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.