daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR
git clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
Log | Files | Refs | README | LICENSE

sip-session-initiation-protocol.md (25012B)


      1 ---
      2 title: "SIP (Session Initiation Protocol)"
      3 section: "Network Services"
      4 sectionSlug: "network-services-pentesting"
      5 sourcePath: "src/network-services-pentesting/pentesting-voip/basic-voip-protocols/sip-session-initiation-protocol.md"
      6 sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-voip/basic-voip-protocols/sip-session-initiation-protocol.md"
      7 sha: "188de82beb54e70956b2952367a0af91d26758b8"
      8 isIndex: false
      9 modified: true
     10 license: "CC-BY-NC-4.0"
     11 ---
     12 
     13 # SIP (Session Initiation Protocol)
     14 
     15 ## Basic information<sup>[[4]](#references)</sup>
     16 
     17 SIP (Session Initiation Protocol) is a **signaling and call control protocol** widely used for establishing, modifying, and terminating multimedia sessions, including voice, video, and instant messaging, over IP networks. Developed by the **Internet Engineering Task Force (IETF)**, SIP is defined in **RFC 3261** and has become the de facto standard for VoIP and unified communications.
     18 
     19 Some key features of SIP include:
     20 
     21 1. **Text-based Protocol**: SIP is a text-based protocol, which makes it human-readable and easier to debug. It is based on a request-response model, similar to HTTP, and uses methods like INVITE, ACK, BYE, and CANCEL for controlling call sessions.
     22 2. **Scalability and Flexibility**: SIP is highly scalable and can be used in small-scale deployments as well as large enterprise and carrier-grade environments. It can be easily extended with new features, making it adaptable to various use cases and requirements.
     23 3. **Interoperability**: SIP's widespread adoption and standardization ensure better interoperability between different devices, applications, and service providers, promoting seamless communication across various platforms.
     24 4. **Modular Design**: SIP works with other protocols like **RTP (Real-time Transport Protocol)** for media transmission and **SDP (Session Description Protocol)** for describing multimedia sessions. This modular design allows for greater flexibility and compatibility with different media types and codecs.
     25 5. **Proxy and Redirect Servers**: SIP can use proxy and redirect servers to facilitate call routing and provide advanced features like call forwarding, call transfer, and voicemail services.
     26 6. **Presence and Instant Messaging**: SIP is not limited to voice and video communication. It also supports presence and instant messaging, enabling a wide range of unified communication applications.
     27 
     28 Despite its many advantages, SIP can be complex to configure and manage, particularly when dealing with NAT traversal and firewall issues. However, its versatility, scalability, and extensive support across the industry make it a popular choice for VoIP and multimedia communication.
     29 
     30 ### SIP methods<sup>[[4]](#references)</sup>
     31 
     32 The core SIP methods defined in **RFC 3261** include:
     33 
     34 1. **INVITE**: Used to **initiate a new session (call)** or modify an existing one. The INVITE method carries the session description (typically using SDP) to inform the recipient about the details of the proposed session, such as media types, codecs, and transport protocols.
     35 2. **ACK**: Sent to **confirm the receipt** of a final response to an INVITE request. The ACK method ensures the reliability of INVITE transactions by providing end-to-end acknowledgement.
     36 3. **BYE**: Used to **terminate an established session (call)**. The BYE method is sent by either party in the session to indicate that they wish to end the communication.
     37 4. **CANCEL**: Sent to **cancel a pending INVITE** request before the session is established. The CANCEL method allows the sender to abort an INVITE transaction if they change their mind or if there is no response from the recipient.
     38 5. **OPTIONS**: Used to **query the capabilities of a SIP server or user agent**. The OPTIONS method can be sent to request information about supported methods, media types, or other extensions without actually establishing a session.
     39 6. **REGISTER**: Used by a user agent to **register its current location with a SIP registrar server**. The REGISTER method helps in maintaining an up-to-date mapping between a user's SIP URI and their current IP address, enabling call routing and delivery.
     40 
     41 > [!WARNING]
     42 > A caller does **not need to use `REGISTER`** to call another party.\
     43 > The caller may nevertheless need to authenticate before sending an **`INVITE`**, or the server will return **`401 Unauthorized`**.
     44 
     45 In addition to these core methods, there are **several SIP extension methods** defined in other RFCs, such as:
     46 
     47 1. **SUBSCRIBE**: Defined in RFC 6665, the SUBSCRIBE method is used to **request notifications** about the state of a specific resource, such as a user's presence or call status.
     48 2. **NOTIFY**: Also defined in RFC 6665, the NOTIFY method is sent by a server to **inform a subscribed user agent** about changes in the state of a monitored resource.
     49 3. **REFER**: Defined in RFC 3515, the REFER method is used to **request that the recipient performs a transfer or refers to a third party**. This is typically used for **call transfer** scenarios.
     50 4. **MESSAGE**: Defined in RFC 3428, the MESSAGE method is used to **send instant messages between SIP user agents**, enabling text-based communication within the SIP framework.
     51 5. **UPDATE**: Defined in RFC 3311, the UPDATE method allows **modifying a session without affecting the state of the existing dialog**. This is useful for updating session parameters, such as codecs or media types, during an ongoing call.
     52 6. **PUBLISH**: Defined in RFC 3903, the PUBLISH method is used by a user agent to **publish event state information to a server**, making it available to other interested parties.
     53 
     54 ### SIP response codes<sup>[[5]](#references)</sup>
     55 
     56 - **1xx (Provisional Responses)**: These responses indicate that the request was received, and the server is continuing to process it.
     57   - 100 Trying: The request was received, and the server is working on it.
     58   - 180 Ringing: The callee is being alerted and will take the call.
     59   - 183 Session Progress: Provides information about the progress of the call.
     60 - **2xx (Successful Responses)**: These responses indicate that the request was successfully received, understood, and accepted.
     61   - 200 OK: The request was successful, and the server has fulfilled it.
     62   - 202 Accepted: The request was accepted for processing, but it hasn't been completed yet.
     63 - **3xx (Redirection Responses)**: These responses indicate that further action is required to fulfill the request, typically by contacting an alternate resource.
     64   - 300 Multiple Choices: There are multiple options available, and the user or client must choose one.
     65   - 301 Moved Permanently: The requested resource has been assigned a new permanent URI.
     66   - 302 Moved Temporarily: The requested resource is temporarily available at a different URI.
     67   - 305 Use Proxy: The request must be sent to a specified proxy.
     68 - **4xx (Client Error Responses)**: These responses indicate that the request contains bad syntax or cannot be fulfilled by the server.
     69   - 400 Bad Request: The request was malformed or invalid.
     70   - 401 Unauthorized: The request requires user authentication.
     71   - 403 Forbidden: The server understood the request but refuses to fulfill it.
     72   - 404 Not Found: The requested resource was not found on the server.
     73   - 408 Request Timeout: The server did not receive a complete request within the time it was prepared to wait.
     74   - 486 Busy Here: The callee is currently busy and unable to take the call.
     75 - **5xx (Server Error Responses)**: These responses indicate that the server failed to fulfill a valid request.
     76   - 500 Internal Server Error: The server encountered an error while processing the request.
     77   - 501 Not Implemented: The server does not support the functionality required to fulfill the request.
     78   - 503 Service Unavailable: The server is currently unable to handle the request due to maintenance or overload.
     79 - **6xx (Global Failure Responses)**: These responses indicate that the request cannot be fulfilled by any server.
     80   - 600 Busy Everywhere: All possible destinations for the call are busy.
     81   - 603 Decline: The callee does not wish to participate in the call.
     82   - 604 Does Not Exist Anywhere: The requested resource is not available anywhere in the network.
     83 
     84 ## Examples<sup>[[4]](#references)</sup>
     85 
     86 ### SIP INVITE Example
     87 
     88 ```text
     89 INVITE sip:jdoe@example.com SIP/2.0
     90 Via: SIP/2.0/UDP pc33.example.com;branch=z9hG4bK776asdhds
     91 Max-Forwards: 70
     92 To: John Doe <sip:jdoe@example.com>
     93 From: Jane Smith <sip:jsmith@example.org>;tag=1928301774
     94 Call-ID: a84b4c76e66710
     95 CSeq: 314159 INVITE
     96 Contact: <sip:jsmith@pc33.example.com>
     97 User-Agent: ExampleSIPClient/1.0
     98 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
     99 Content-Type: application/sdp
    100 Content-Length: 142
    101 
    102 v=0
    103 o=jsmith 2890844526 2890842807 IN IP4 pc33.example.com
    104 s=-
    105 c=IN IP4 pc33.example.com
    106 t=0 0
    107 m=audio 49170 RTP/AVP 0
    108 a=rtpmap:0 PCMU/8000
    109 ```
    110 
    111 <details>
    112 
    113 <summary>Each Param Explained</summary>
    114 
    115 1. **Request-Line**: `INVITE sip:jdoe@example.com SIP/2.0` - This line indicates the method (INVITE), the request URI (sip:[jdoe@example.com](mailto:jdoe@example.com)), and the SIP version (SIP/2.0).
    116 2. **Via**: `Via: SIP/2.0/UDP pc33.example.com;branch=z9hG4bK776asdhds` - The Via header specifies the transport protocol (UDP) and the client's address (pc33.example.com). The "branch" parameter is used for loop detection and transaction matching.
    117 3. **Max-Forwards**: `Max-Forwards: 70` - This header field limits the number of times the request can be forwarded by proxies to avoid infinite loops.
    118 4. **To**: `To: John Doe <sip:jdoe@example.com>` - The To header specifies the recipient of the call, including their display name (John Doe) and SIP URI (sip:[jdoe@example.com](mailto:jdoe@example.com)).
    119 5. **From**: `From: Jane Smith <sip:jsmith@example.org>;tag=1928301774` - The From header specifies the sender of the call, including their display name (Jane Smith) and SIP URI (sip:[jsmith@example.org](mailto:jsmith@example.org)). The "tag" parameter is used to uniquely identify the sender's role in the dialog.
    120 6. **Call-ID**: `Call-ID: a84b4c76e66710` - The Call-ID header uniquely identifies a call session between two user agents.
    121 7. **CSeq**: `CSeq: 314159 INVITE` - The CSeq header contains a sequence number and the method used in the request. It's used to match responses to requests and detect out-of-order messages.
    122 8. **Contact**: `Contact: <sip:jsmith@pc33.example.com>` - The Contact header provides a direct route to the sender, which can be used for subsequent requests and responses.
    123 9. **User-Agent**: `User-Agent: ExampleSIPClient/1.0` - The User-Agent header provides information about the software or hardware of the sender, including its name and version.
    124 10. **Allow**: `Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO` - The Allow header lists the SIP methods supported by the sender. This helps the recipient understand which methods can be used during the communication.
    125 11. **Content-Type**: `Content-Type: application/sdp` - The Content-Type header specifies the media type of the message body, in this case, SDP (Session Description Protocol).
    126 12. **Content-Length**: `Content-Length: 142` - The Content-Length header indicates the size of the message body in bytes.
    127 13. **Message Body**: The message body contains the SDP session description, which includes information about the media types, codecs, and transport protocols for the proposed session.
    128 
    129 - `v=0` - Protocol version (0 for SDP)
    130 - `o=jsmith 2890844526 2890842807 IN IP4 pc33.example.com` - Originator and session identifier
    131 - `s=-` - Session name (a single hyphen indicates no session name)
    132 - `c=IN IP4 pc33.example.com` - Connection information (network type, address type, and address)
    133 - `t=0 0` - Timing information (start and stop times, 0 0 means the session is not bounded)
    134 - `m=audio 49170 RTP/AVP 0` - Media description (media type, port number, transport protocol, and format list). In this case, it specifies an audio stream using RTP/AVP (Real-time Transport Protocol / Audio Video Profile) and format 0 (PCMU/8000).
    135 - `a=rtpmap:0 PCMU/8000` - Attribute mapping the format (0) to the codec (PCMU) and its clock rate (8000 Hz).
    136 
    137 </details>
    138 
    139 ### SIP REGISTER Example
    140 
    141 The REGISTER method is used in Session Initiation Protocol (SIP) to allow a user agent (UA), such as a VoIP phone or a softphone, to **register its location with a SIP registrar server**. This process lets the server know **where to route incoming SIP requests destined for the registered user**. The registrar server is usually part of a SIP proxy server or a dedicated registration server.
    142 
    143 Here's a detailed example of the SIP messages involved in a REGISTER authentication process:
    144 
    145 1. Initial **REGISTER** request from UA to the registrar server:
    146 
    147 ```yaml
    148 REGISTER sip:example.com SIP/2.0
    149 Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
    150 Max-Forwards: 70
    151 From: Alice <sip:alice@example.com>;tag=565656
    152 To: Alice <sip:alice@example.com>
    153 Call-ID: 1234567890@192.168.1.100
    154 CSeq: 1 REGISTER
    155 Contact: <sip:alice@192.168.1.100:5060>;expires=3600
    156 Expires: 3600
    157 Content-Length: 0
    158 ```
    159 
    160 This initial REGISTER message is sent by the UA (Alice) to the registrar server. It includes important information such as the desired registration duration (Expires), the user's SIP URI (sip:[alice@example.com](mailto:alice@example.com)), and the user's contact address (sip:alice@192.168.1.100:5060).
    161 
    162 2. **401 Unauthorized** response from the registrar server:
    163 
    164 ```text
    165 SIP/2.0 401 Unauthorized
    166 Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
    167 From: Alice <sip:alice@example.com>;tag=565656
    168 To: Alice <sip:alice@example.com>;tag=7878744
    169 Call-ID: 1234567890@192.168.1.100
    170 CSeq: 1 REGISTER
    171 WWW-Authenticate: Digest realm="example.com", nonce="abcdefghijk", algorithm=MD5, qop="auth"
    172 Content-Length: 0
    173 ```
    174 
    175 The registrar server responds with a "401 Unauthorized" message, which includes a "WWW-Authenticate" header. This header contains information required for the UA to authenticate itself, such as the **authentication realm, nonce, and algorithm**.
    176 
    177 3. REGISTER request **with authentication credentials**:
    178 
    179 ```text
    180 REGISTER sip:example.com SIP/2.0
    181 Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
    182 Max-Forwards: 70
    183 From: Alice <sip:alice@example.com>;tag=565656
    184 To: Alice <sip:alice@example.com>
    185 Call-ID: 1234567890@192.168.1.100
    186 CSeq: 2 REGISTER
    187 Contact: <sip:alice@192.168.1.100:5060>;expires=3600
    188 Expires: 3600
    189 Authorization: Digest username="alice", realm="example.com", nonce="abcdefghijk", uri="sip:example.com", response="65a8e2285879283831b664bd8b7f14d4", algorithm=MD5, cnonce="lmnopqrst", qop=auth, nc=00000001
    190 Content-Length: 0
    191 ```
    192 
    193 The UA sends another REGISTER request, this time including the **"Authorization" header with the necessary credentials, such as the username, realm, nonce, and a response value** calculated using the provided information and the user's password.
    194 
    195 This is how the **Authorization response** is calculated:
    196 
    197 ```python
    198 import hashlib
    199 
    200 def calculate_sip_md5_response(username, password, realm, method, uri, nonce, nc, cnonce, qop):
    201     # 1. Calculate HA1 (concatenation of username, realm, and password)
    202     ha1_input = f"{username}:{realm}:{password}"
    203     ha1 = hashlib.md5(ha1_input.encode()).hexdigest()
    204 
    205     # 2. Calculate HA2 (concatenation of method and uri)
    206     ha2_input = f"{method}:{uri}"
    207     ha2 = hashlib.md5(ha2_input.encode()).hexdigest()
    208 
    209     # 3. Calculate the final response value (concatenation of h1, stuff and h2)
    210     response_input = f"{ha1}:{nonce}:{nc}:{cnonce}:{qop}:{ha2}"
    211     response = hashlib.md5(response_input.encode()).hexdigest()
    212 
    213     return response
    214 
    215 # Example usage
    216 username = "alice"
    217 password = "mysecretpassword"
    218 realm = "example.com"
    219 method = "REGISTER"
    220 uri = "sip:example.com"
    221 nonce = "abcdefghijk"
    222 nc = "00000001"
    223 cnonce = "lmnopqrst"
    224 qop = "auth"
    225 
    226 response = calculate_sip_md5_response(username, password, realm, method, uri, nonce, nc, cnonce, qop)
    227 print(f"MD5 response value: {response}")
    228 ```
    229 
    230 4. **Successful registration** response from the registrar server:
    231 
    232 ```yaml
    233 SIP/2.0 200 OK
    234 Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
    235 From: Alice <sip:alice@example.com>;tag=565656
    236 To: Alice <sip:alice@example.com>;tag=7878744
    237 Call-ID: 1234567890@192.168.1.100
    238 CSeq: 2 REGISTER
    239 Contact: <sip:alice@192.168.1.100:5060>;expires=3600
    240 Expires: 3600
    241 Content-Length: 0
    242 ```
    243 
    244 After the registrar server verifies the provided credentials, **it sends a "200 OK" response to indicate that the registration was successful**. The response includes the registered contact information and the expiration time for the registration. At this point, the user agent (Alice) is successfully registered with the SIP registrar server, and incoming SIP requests for Alice can be routed to the appropriate contact address.
    245 
    246 ### Call Example
    247 
    248 <figure><img src="https://raw.githubusercontent.com/HackTricks-wiki/hacktricks/188de82beb54e70956b2952367a0af91d26758b8/src/images/image%20%281101%29.png" alt=""><figcaption></figcaption></figure>
    249 
    250 > [!TIP]
    251 > It's not mentioned, but User B needs to have sent a **REGISTER message to Proxy 2** before he is able to receive calls.
    252 
    253 
    254 ---
    255 
    256 ## SIP Security and Pentesting Notes
    257 
    258 This section adds practical, protocol-specific tips without duplicating the broader VoIP guidance. For end-to-end VoIP attacking methodology, tools and scenarios, see:
    259 
    260 [Readme](/hacktricks/network-services-pentesting/pentesting-voip/overview)
    261 
    262 ### Fingerprinting and Discovery
    263 
    264 - Send an OPTIONS request and review `Allow`, `Supported`, `Server` and `User-Agent` headers to fingerprint devices and stacks:
    265   
    266   ```bash
    267   # nmap NSE (UDP 5060 by default)
    268   sudo nmap -sU -p 5060 --script sip-methods <target>
    269   
    270   # Minimal raw OPTIONS over UDP
    271   printf "OPTIONS sip:<target> SIP/2.0\r\nVia: SIP/2.0/UDP attacker;branch=z9\r\nFrom: <sip:probe@attacker>;tag=1\r\nTo: <sip:probe@<target>>\r\nCall-ID: 1@attacker\r\nCSeq: 1 OPTIONS\r\nMax-Forwards: 70\r\nContact: <sip:probe@attacker>\r\nContent-Length: 0\r\n\r\n" | nc -u -w 2 <target> 5060
    272   ```
    273 
    274 ### Username/Extension Enumeration Behavior
    275 
    276 - Enumeration typically abuses differences between `401/407` vs `404/403` on `REGISTER`/`INVITE`. Harden servers to reply uniformly.
    277   - Asterisk chan_sip: set `alwaysauthreject=yes` (general) to avoid disclosing valid users. In newer Asterisk (PJSIP), guest calling is disabled unless an `anonymous` endpoint is defined and similar "always auth reject" behavior is the default; still enforce network ACLs and fail2ban at the perimeter.
    278 
    279 ### SIP Digest Authentication: algorithms and cracking
    280 
    281 - SIP commonly uses HTTP-Digest style auth. Historically MD5 (and MD5-sess) are prevalent; newer stacks support SHA-256 and SHA-512/256 per RFC 8760.<sup>[[2]](#references)</sup> Prefer these stronger algorithms in modern deployments and disable MD5 when possible.
    282 - Offline cracking from a PCAP is practical for weak MD5 digests. After extracting the challenge/response, you can use Hashcat mode 11400 (SIP digest, MD5):
    283   
    284   ```bash
    285   # Example hash format (single line)
    286   # username:realm:method:uri:nonce:cnonce:nc:qop:response
    287   echo 'alice:example.com:REGISTER:sip:example.com:abcdef:11223344:00000001:auth:65a8e2285879283831b664bd8b7f14d4' > sip.hash
    288   
    289   # Crack with a wordlist
    290   hashcat -a 0 -m 11400 sip.hash /path/to/wordlist.txt
    291   ```
    292 
    293 > [!NOTE]
    294 > RFC 8760 defines SHA-256 and SHA-512/256 for HTTP Digest (used by SIP). Adoption is uneven; ensure your tools handle these when targeting modern PBXs.<sup>[[2]](#references)</sup>
    295 
    296 ### SIP over TLS (SIPS) and over WebSockets
    297 
    298 - Signaling encryption:
    299   - `sips:` URIs and TCP/TLS typically on 5061. Verify certificate validation on endpoints; many accept self-signed or wildcard certs, enabling MitM in weak deployments.
    300   - WebRTC softphones often use SIP over WebSocket per RFC 7118 (`ws://` or `wss://`). If the PBX exposes WSS, test authentication and CORS, and ensure rate limits are enforced on the HTTP front end as well.
    301 
    302 ### DoS quick checks (protocol level)
    303 
    304 - Flooding INVITE, REGISTER or malformed messages can exhaust transaction processing.
    305 - Simple rate-limiting example for UDP/5060 (Linux iptables hashlimit):
    306   
    307   ```bash
    308   # Limit new SIP packets from a single IP to 20/s with burst 40
    309   iptables -A INPUT -p udp --dport 5060 -m hashlimit \
    310     --hashlimit-name SIP --hashlimit 20/second --hashlimit-burst 40 \
    311     --hashlimit-mode srcip -j ACCEPT
    312   iptables -A INPUT -p udp --dport 5060 -j DROP
    313   ```
    314 
    315 ### Recent, relevant SIP-stack CVE to watch (Asterisk PJSIP)
    316 
    317 - CVE-2024-35190 (published May 17, 2024): In specific Asterisk releases, `res_pjsip_endpoint_identifier_ip` could misidentify unauthorized SIP requests as a local endpoint, potentially enabling unauthorized actions or information exposure. Fixed in 18.23.1, 20.8.1 and 21.3.1. Validate your PBX version when testing and report responsibly.<sup>[[3]](#references)</sup>
    318 
    319 ### SDP/ICE candidate parsing as an RCE surface
    320 
    321 SIP endpoints often parse **embedded SDP** from `INVITE` requests before authentication or user interaction. If optional **ICE** support is enabled, `a=candidate:` attributes become an extra parser attack surface that is easy to miss during reviews because the bug lives in the **SDP helper**, not in the top-level SIP state machine.<sup>[[1]](#references)</sup>
    322 
    323 - **Reachability pattern**: `INVITE` over UDP/5060 -> `Content-Type: application/sdp` -> SDP line starting with `a=candidate:` -> ICE-specific parser.
    324 - **Common bug class**: copy the full candidate line into a **fixed stack buffer** with `memcpy`/`strcpy` and then NUL-terminate it **without checking the destination size**.
    325 - **Exploit validation on ARM**: build the candidate as `a=candidate:` + fill bytes + register markers, then confirm control of saved registers / `pc` in the crash dump. When the exact prefix length matters, count protocol bytes first.
    326 - **Why this matters**: SIP parsers frequently run as a privileged monolithic process inside phones/PBX components, so a parser bug in a rarely-used feature can still become **unauthenticated RCE**.
    327 
    328 Minimal malformed body pattern:
    329 
    330 ```text
    331 c=IN IP4 192.0.2.10
    332 m=audio 40000 RTP/AVP 0
    333 a=rtpmap:0 PCMU/8000/1
    334 a=candidate:AAAA...[oversized candidate line]...
    335 ```
    336 
    337 #### Practical exploitation workflow for SIP/SDP parser bugs
    338 
    339 1. **Confirm the feature gate**: look for device/PBX options enabling ICE, TURN, STUN, SRTP negotiation, video, or vendor extensions.
    340 2. **Trigger the parser with a valid SIP envelope** so the malformed field reaches the deep protocol helper instead of being rejected by superficial syntax checks.
    341 3. **Measure the exact overwrite layout** from the field prefix to the saved return state (`pc`/`lr` on ARM, `rip` on x86_64).
    342 4. **Run `checksec` / inspect mitigations** to decide between shellcode, ret2libc, or a full ROP chain.
    343 5. If **NX** is enabled and the main binary is non-PIE but loaded at addresses containing **NUL bytes**, check `/proc/<pid>/maps` for **shared libraries mapped at stable non-null bases** and pivot the ROP chain there instead of using low-address gadgets from the main binary.
    344 
    345 > [!TIP]
    346 > Text-based protocol exploit development is often constrained by forbidden bytes (`0x00`, `\r`, `\n`, separators such as `:` or space). When choosing gadgets or fake arguments, validate that the full address encoding survives the parser and any tokenization step.
    347 
    348 ### Hardening checklist (SIP-specific)
    349 
    350 - Prefer TLS for signaling and SRTP/DTLS-SRTP for media; disable cleartext where feasible.
    351 - Enforce strong passwords and digest algorithms (SHA-256/512-256 where supported; avoid MD5).
    352 - For Asterisk:
    353   - chan_sip: `alwaysauthreject=yes`, `allowguest=no`, per-endpoint `permit`/`deny` CIDR ACLs.
    354   - PJSIP: do not create an `anonymous` endpoint unless needed; enforce endpoint `acl`/`media_acl`; enable fail2ban or equivalent.
    355 - Topology hiding on SIP proxies (e.g., outbound proxy/edge SBC) to reduce information leakage.
    356 - Strict `OPTIONS` handling and rate limits; disable unused methods (e.g., `MESSAGE`, `PUBLISH`) if not required.
    357 
    358 ## References
    359 
    360 - [1] [Rapid7: CVE-2026-0826 - Critical unauthenticated stack buffer overflow in HP Poly VVX and Trio VoIP Phones](https://www.rapid7.com/blog/post/ve-cve-2026-0826-critical-unauthenticated-stack-buffer-overflow-hp-poly-vvx-trio-voip-phones-fixed/)
    361 - [2] [RFC 8760 – Using SHA-256 and SHA-512/256 for HTTP Digest (applies to SIP Digest too)](https://www.rfc-editor.org/rfc/rfc8760)
    362 - [3] [Asterisk Security Advisory GHSA-qqxj-v78h-hrf9 for CVE-2024-35190](https://github.com/asterisk/asterisk/security/advisories/GHSA-qqxj-v78h-hrf9)
    363 - [4] [RFC 3261 – SIP: Session Initiation Protocol](https://www.rfc-editor.org/rfc/rfc3261)
    364 - [5] [IANA – Session Initiation Protocol (SIP) Parameters](https://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml)