VYPR
Medium severity6.1NVD Advisory· Published Dec 29, 2017· Updated May 13, 2026

CVE-2017-16876

CVE-2017-16876

Description

Cross-site scripting (XSS) vulnerability in the _keyify function in mistune.py in Mistune before 0.8.1 allows remote attackers to inject arbitrary web script or HTML by leveraging failure to escape the "key" argument.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
mistunePyPI
< 0.8.10.8.1

Affected products

2

Patches

1
5f06d724bc05

Fix CVE-2017-16876

https://github.com/lepture/mistuneHsiaoming YangNov 20, 2017via ghsa
1 file changed · +5 3
  • mistune.py+5 3 modified
    @@ -11,7 +11,7 @@
     import re
     import inspect
     
    -__version__ = '0.8'
    +__version__ = '0.8.1'
     __author__ = 'Hsiaoming Yang <me@lepture.com>'
     __all__ = [
         'BlockGrammar', 'BlockLexer',
    @@ -48,7 +48,8 @@ def _pure_pattern(regex):
     
     
     def _keyify(key):
    -    return _key_pattern.sub(' ', key.lower())
    +    key = escape(key.lower(), quote=True)
    +    return _key_pattern.sub(' ', key)
     
     
     def escape(text, quote=False, smart_amp=True):
    @@ -445,7 +446,8 @@ class InlineGrammar(object):
         inline_html = re.compile(
             r'^(?:%s|%s|%s)' % (
                 r'<!--[\s\S]*?-->',
    -            r'<(\w+%s)((?:%s)*?)\s*>([\s\S]*?)<\/\1>' % (_valid_end, _valid_attr),
    +            r'<(\w+%s)((?:%s)*?)\s*>([\s\S]*?)<\/\1>' % (
    +                _valid_end, _valid_attr),
                 r'<\w+%s(?:%s)*?\s*\/?>' % (_valid_end, _valid_attr),
             )
         )
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

8

News mentions

0

No linked articles in our index yet.