DEV Community

Cover image for ๐Ÿ”’ VoIP Security 101
SIP GAMES
SIP GAMES

Posted on

๐Ÿ”’ VoIP Security 101

"In VoIP, itโ€™s not enough to play the game โ€” sometimes you need to play it in stealth mode."


In previous levels, we built up VoIP basics:

  • SIP to set up calls
  • SDP to negotiate media
  • RTP to carry voice and video

But what happens when the arena is hostile? Eavesdroppers, man-in-the-middle attacks, or even malicious proxies could steal or tamper with calls. Thatโ€™s where VoIP security comes in.


๐ŸŽญ Securing the Two Worlds: Signaling vs Media

VoIP has two layers to protect:

  1. Signaling (SIP) โ€” Whoโ€™s calling, how, where to connect.
  2. Media (RTP) โ€” The actual voice/video packets.

Both require different protection strategies.


๐Ÿ“ž Securing Signaling with SIPS

SIP normally rides on plain UDP or TCP. Thatโ€™s like mailing postcards โ€” anyone along the route can read them.

The fix? Transport Layer Security (TLS).

  • SIP over TLS (SIPS) encrypts SIP signaling between endpoints and proxies.
  • Port convention: 5061 instead of 5060.
  • Certificates are used to authenticate servers (and optionally clients).

Example flow:

[Caller SIP UA] --TLS--> [SIP Proxy] --TLS--> [Callee SIP UA]
Enter fullscreen mode Exit fullscreen mode

Think of it as wrapping your SIP messages in an armored envelope.


๐ŸŽง Securing Media with SRTP

While SIPS hides setup instructions, the media path (RTP) still needs protection. Thatโ€™s where Secure RTP (SRTP) comes in.

SRTP encrypts and authenticates RTP streams, ensuring that:

  • Nobody can eavesdrop on your audio/video.
  • Nobody can inject fake packets into the stream.

But SRTP alone isnโ€™t enough โ€” it needs a way to exchange keys. This is where different methods come in.


๐Ÿ”‘ Key Exchange Mechanisms for SRTP

1. SRTP with SDES (Session Description Protocol Security Descriptions)

With SDES, keys are shared inside the SDP body of SIP messages.

Example SDP with SDES:

v=0
o=- 12345 67890 IN IP4 192.0.2.1
s=VoIP Call
c=IN IP4 192.0.2.1
t=0 0
m=audio 49170 RTP/AVP 0
a=rtpmap:0 PCMU/8000
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:MTIzNDU2Nzg5MDEyMzQ1Ng==
Enter fullscreen mode Exit fullscreen mode
  • a=crypto defines the encryption algorithm and key.
  • AES_CM_128_HMAC_SHA1_80 = AES with HMAC authentication.
  • The inline: value is the base64-encoded SRTP key.

โš ๏ธ Risk: If SIP isnโ€™t protected with TLS, anyone sniffing the signaling path can steal the SRTP key.

๐Ÿ‘‰ Best for: Controlled/trusted networks where SIP signaling is already protected with TLS.

2. SRTP with DTLS (Datagram Transport Layer Security)

DTLS provides a handshake (like TLS for UDP) to exchange SRTP keys directly between endpoints.
Instead of placing keys in SDP, endpoints exchange fingerprints for certificate verification.

Example SDP with DTLS-SRTP:

v=0
o=- 46117326 2 IN IP4 192.0.2.10
s=VoIP Call
c=IN IP4 192.0.2.10
t=0 0
m=audio 54000 RTP/SAVPF 111 0
a=rtpmap:111 opus/48000/2
a=rtpmap:0 PCMU/8000
a=setup:actpass
a=fingerprint:sha-256 12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF
a=ice-ufrag:abcd
a=ice-pwd:efghijklmnop
Enter fullscreen mode Exit fullscreen mode

Key lines explained:

  • a=setup:
    • actpass โ†’ Caller offers to act as either client or server.
    • active โ†’ Endpoint will initiate DTLS handshake.
    • passive โ†’ Endpoint will wait for DTLS handshake.
  • a=fingerprint: โ†’ Hash of the certificate used for DTLS session. Ensures authenticity.
  • RTP/SAVPF โ†’ Secure RTP profile with feedback (commonly used in WebRTC).

๐Ÿ‘‰ Best for: WebRTC and modern SIP deployments. Provides stronger end-to-end protection.


๐ŸŒ Transport Security Recap

  • SIP signaling:

    • UDP/TCP โ†’ Plaintext, insecure.
    • TLS โ†’ Encrypted (SIPS).
  • RTP media:

    • Plain RTP โ†’ Insecure.
    • SRTP/SDES โ†’ Keys in SIP/SDP, simpler.
    • SRTP/DTLS โ†’ Keys exchanged via DTLS handshake, stronger.

๐Ÿ“Š Quick Comparison Table

Layer Plain Protocol Secure Protocol Notes
SIP SIP over UDP/TCP SIPS (SIP over TLS) Protects signaling from eavesdropping
RTP RTP SRTP Encrypts and authenticates media
SRTP Keying N/A SDES Keys exchanged via SDP (requires SIPS)
SRTP Keying N/A DTLS Keys exchanged via DTLS handshake (WebRTC)

๐ŸŽฎ TL;DR

  • SIPS (TLS) secures SIP signaling.
  • SRTP secures the media path.
    • SDES = simpler, but requires trusted signaling.
    • DTLS = modern, secure, and WebRTC-approved.

๐Ÿง  Up Next in SIP GAMES:

โ€œChoose Your Fighter: SIP Call Scenariosโ€ ๐ŸŽฌ
Weโ€™ll break down real-world call flows and SIP requests โ€” INVITE, BYE, REFER, REGISTER, and more โ€” showing how signaling changes in different situations (basic calls, transfers, forking).

Stay tuned, because the next level is all about SIP Requests in Action.

Follow @sip_games

Top comments (0)