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

snmp: Validate input data #431

Closed
wants to merge 2 commits into from
Closed

Commits on Jul 19, 2022

  1. snmp: Validate length fields before use

    The snmp code does not prevent overflows during pointer arithmetics on
    32 bit architectures. Check length before performing additions.
    
    This can lead to out of boundary accesses or endless loops if
    debug output is enabled (proof of concept exists for OOB access).
    
    Proof of Concept:
    
    1. Create and run server with crashing payload
    
    ```
    cat > poc.py << EOF
    from socket import AF_INET, SOCK_DGRAM, socket
    s=socket(AF_INET, SOCK_DGRAM)
    s.bind(('',161))
    print('Waiting for incoming SNMP data')
    m, addr=s.recvfrom(1024)
    print('Replying with crash payload')
    s.sendto(b'\x30\x07\x02\x84\xDE\xAD\xBA\xBE\x00', addr)
    EOF
    sudo python poc.py
    ```
    
    2. Run snmp backend (or try to "Add Printer")
    
    `/usr/lib/cups/backend/snmp localhost`
    ferivoz committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    d7ecddc View commit details
    Browse the repository at this point in the history
  2. snmp: Prevent signed integer overflows

    Shifting bits into highest bit of integers is undefined behavior
    according to C standards.
    
    It can be easily prevented by using an unsigned type during shifts,
    casting to signed at the end.
    ferivoz committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    6bf3e5c View commit details
    Browse the repository at this point in the history