Skip to content

sectxt PGP parsing can raise IndexError from pgpy #85

Closed

Description

@mxsasha

A possibly malformed, or perhaps just unusual, security.txt, can raise an IndexError from pgpy.

IndexError: bytearray index out of range
...
  File "checks/tasks/securitytxt.py", line 138, in _evaluate_securitytxt
    parser = sectxt.Parser(result.content, urls=result.found_url)
  File "__init__.py", line 93, in __init__
    self._process()
  File "__init__.py", line 100, in _process
    self._line_info.append(self._parse_line(line))
  File "__init__.py", line 165, in _parse_line
    pgpy.PGPMessage.from_blob(self._content_str)
  File "pgpy/types.py", line 195, in from_blob
    po = obj.parse(bytearray(blob, 'latin-1'))
  File "pgpy/pgp.py", line 1285, in parse
    pkt = Packet(data)
  File "pgpy/types.py", line 508, in __call__
    header.parse(packet)
  File "pgpy/packet/types.py", line 109, in parse
    self.length = packet
  File "pgpy/decorators.py", line 47, in wrapper
    return sd.dispatch(args[0].__class__)(obj, *args, **kwargs)
  File "pgpy/types.py", line 389, in length_bin
    _new_len(val) if self._lenfmt == 1 else _old_len(val)
  File "pgpy/types.py", line 374, in _new_len
    part_len, size, partial = _parse_len(b, total)
  File "pgpy/types.py", line 349, in _parse_len
    fo = a[offset]

Found for klikonderwijs.nl. Does not immediately look strange. Confirmed on 0.9.6.

internetstandards/Internet.nl#1737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions