Skip to content

Crashes in chksidroot upon exotic path chararacters #330

@jonasbardino

Description

@jonasbardino

We see occasional crashes like these in the chksidroot log emission as a result of security scans:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib64/python3.9/logging/__init__.py", line 1086, in emit
    stream.write(msg + self.terminator)
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 114-117: surrogates not allowed
Call stack:
  File "/home/mig/mig/server/chksidroot.py", line 140, in <module>
    logger.warning("got path from %s with invalid root: %s" %
Message: 'got path from REDACTED_IP with invalid root: REDACTED_PATH/webserver_home/c:\udcc0\udcae\udcc0\udcae\\\udcc0\udcae\udcc0\udcae\\\udcc0\udcae\udcc0\udcae\\\udcc0\udcae\udcc0\udcae\\\udcc0\udcae\udcc0\udcae\\\udcc0\udcae\udcc0\udcae\\etc\\passwd#vt/test'
Arguments: ()

It will crash and thus prevent access but we should not let the interpreter try to decode the byte sequence as utf-8 at all when logging.
Same most likely applies for the similar chkuserroot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions