concept size in category security

appears as: size, size
API Security Starter

This is an excerpt from Manning's book API Security Starter.

  • Last, there may be security vulnerabilities due to the implementation of the API. For example, failing to check the size of inputs to your API may allow an attacker to bring down your server by sending a very large input that consumes all available memory; a type of denial of service (DoS) attack.
  • Table 4.3 Contract for keeping track of cat names
    Method Precondition requires Postcondition ensures
    nextCatName Must contain something size is the same after call
    name is guaranteed to contain s (a sound)
    dequeueCatName Must contain something size is one less after call
    queueCatName name isn’t nullname must contain s (a sound)
    name isn’t in list
    size is one more after call
    Secure by Design

    This is an excerpt from Manning's book Secure by Design.

    The Billion Laughs attack is as simple as it is effective. The main idea is to exploit the expandability property of XML entities by defining recursive definitions that expand into a huge memory footprint. Listing 1.8 shows an example of the attack that’s defined by a small XML block, less than 1 KB in size. This allows the block to pass most validation checks that rely on size or length. When the XML is loaded by the parser, lol9 expands into 10 lol8s, which then expands into 100 lol7s, and so on. This finally results in a billion lol strings that consume several gigabytes of memory.

    Table 4.3 Contract for keeping track of cat names (view table figure)
    Method Precondition requires Postcondition ensures
    nextCatName Must contain something size is the same after call
    name is guaranteed to contain s (a sound)
    dequeueCatName Must contain something size is one less after call
    queueCatName name isn’t nullname must contain s (a sound)
    name isn’t in list
    size is one more after call