1
0
mirror of https://github.com/coturn/coturn.git synced 2026-04-12 07:41:42 +02:00

1849 Commits

Author SHA1 Message Date
Pavel Punsky
41ba6d8f5d
Update version to 4.9.0 (#1813)
Update version to 4.9.0 

Contains security fixes and highly recommended to upgrade
4.9.0
2026-02-23 17:04:31 -08:00
Pavel Punsky
e59f0ffeaa
Fix thread sanitizer warning (#1812)
Resolves all sanitizer warnings caused by
1. simultaneous access to logger time
2. barrier during threads initialization at startup
2026-02-23 16:16:27 -08:00
Pavel Punsky
da30d26ea3
Temporary workaround for windows build (#1811) 2026-02-22 22:57:29 -08:00
Pavel Punsky
b80eb898ba
Merge commit from fork
* Handle IN6_IS_ADDR_V4MAPPED mappings

* Handle IN6_IS_ADDR_V4MAPPED mappings
2026-02-22 19:18:42 -08:00
Pavel Punsky
e5ed78583d
Fixes: int to bool conversion and comparison (#1810)
In multiple places int is converted to bool
2026-02-21 18:27:16 -08:00
Pavel Punsky
4c674289a8
OpenSSL: migrate to modern API for DH param (#1809)
Use openssl-3.0 apis
2026-02-21 17:31:17 -08:00
Pavel Punsky
6c38ccb08d
Migrate AES-128 encryption from deprecated OpenSSL API to EVP (#1808)
The AES_encrypt, AES_set_encrypt_key, CRYPTO_ctr128_encrypt, and
SSL_CTX_use_RSAPrivateKey_file functions are deprecated in OpenSSL 3.0+
and produce compiler warnings.Replace deprecated low-level OpenSSL
AES/CRYPTO functions with the modern EVP (Envelope) API, and remove the
deprecated SSL_CTX_use_RSAPrivateKey_file fallback.

Changes
encrypt_aes_128 — Replaced AES_set_encrypt_key + CRYPTO_ctr128_encrypt
with EVP_EncryptInit_ex / EVP_EncryptUpdate / EVP_EncryptFinal_ex using
EVP_aes_128_ctr(). Added proper error handling (context cleanup on
failure), input length bounds checking, and enlarged the total buffer
from 256 to 1024 bytes to match the output buffer. The IV was corrected
from 8 to 16 bytes (as required by AES-CTR).

decrypt_aes_128 — Same migration from CRYPTO_ctr128_encrypt to
EVP_DecryptInit_ex / EVP_DecryptUpdate / EVP_DecryptFinal_ex. Added
proper cleanup of both the EVP context and the encryptedText allocation
on every error path. Retained the existing bounds check on newTotalSize.
Output is now explicitly null-terminated using the actual decrypted
length (outlen + final_len).

set_ctx (TLS context setup) — Removed the SSL_CTX_use_RSAPrivateKey_file
fallback that was nested inside the SSL_CTX_use_PrivateKey_file failure
path. SSL_CTX_use_PrivateKey_file already handles RSA keys, so the
RSA-specific fallback was redundant and used a function deprecated since
OpenSSL 3.0.
2026-02-19 18:05:05 -08:00
Pavel Punsky
b209191ba1
Fix unbounded strcpy in stun_method_str (ns_turn_msg.c) (#1798)
## Issue
strcpy(smethod, s) with no size check. Callers pass fixed buffers (e.g.
32 bytes); if API were misused with a smaller
buffer, or s were ever longer, this could overflow.

## Fix
Use strncpy with a fixed maximum (32), then null-terminate,
so at most 32 bytes are written regardless of caller buffer size.
2026-02-16 21:23:10 -08:00
Pavel Punsky
667b661e80
Fix missing null termination in addr_to_string (ns_turn_ioaddr.c) (#1806)
## Issue
Multiple changes in this PR related to address printing (with and
without port)
- Change buffer size to be 64 (enough to hold IPv6 - 46, and port - 5,
and formatting "[ip]:port")
- Align buffer size across all usages (were 65, 129, 256, 257, 1025).
Even 65 is bad - takes extra cache line.
- Change argument to `addr_to_string_no_port`/`addr_to_string` to be of
type char inasted of uint8_t (double converted)
- Eliminate extra buffer in `addr_to_string_no_port`
- Defensively terminate string with null in addr_to_string`

## Explanations
- `addr_to_string_no_port` rely on `inet_ntop` to convert address to
null terminated string
- `addr_to_string` with port==0 rely on `inet_ntop`, otherwise null
terminate at the end of the buffer of size MAX_IOA_ADDR_STRING
2026-02-16 21:20:41 -08:00
Pavel Punsky
77f99e0995
Fix missing null termination after strncpy in DB drivers (#1804)
## Issue
strncpy(realm/pwd, ..., STUN_MAX_*_SIZE) does not append a null. When DB
value length >= size, the buffer was
unterminated, leading to potential reads past buffer in later code.

## Fix
Explicitly set realm[STUN_MAX_REALM_SIZE] and pwd[STUN_MAX_PWD_SIZE] to
'\0' after each strncpy.
2026-02-16 19:19:02 -08:00
Pavel Punsky
ad85332c94
Fix unbounded strcpy in HTTP response (http_server.c) (#1800)
## Issue
strcpy(data, data_http) copied into the network buffer
with no size check. If buffer allocation or layout changed, this
could overflow.

## Fix
Use ioa_network_buffer_get_capacity(), copy at most that many
bytes with memcpy, explicitly null-terminate, and set size accordingly.
2026-02-15 18:48:24 -08:00
Pavel Punsky
8c8bf97a38
Remove ubuntu20, DEBUG builds from build matrix (#1803)
Random failures with tests including prometheus - no time to solve it
now so just disabling

Also, removing DEBUG targets from Windows builds
2026-02-15 18:38:39 -08:00
Pavel Punsky
84f492ad6e
Fix buffer overflow in decryptPassword in mysql (#1801)
## Issue
strcat(last, (char *)outdata) then strcpy(out, last) with last[1024].
outdata is not null-terminated (decryption output),
allowing reads past buffer and possible overflow of last.

## Fix
Use bounded memcpy with explicit null termination, limiting copy to
remaining space in last and sizeof(outdata). Check malloc before strcpy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-15 18:22:56 -08:00
Pavel Punsky
bdacef780b
Fix missing null termination after strncpy in MongoDB driver (dbd_mongo.c) (#1797)
## Issue
strncpy(realm/pwd, ...) without null termination
when source is long left buffers unterminated.

## Fix
Set realm[STUN_MAX_REALM_SIZE] and pwd[STUN_MAX_PWD_SIZE]
to '\0' after each strncpy.
2026-02-15 17:50:40 -08:00
Pavel Punsky
b69ceb4252
Fix buffer overflow in decrypt_aes_128 (#1799)
**Issue**: 

strcat(last, (char *)outdata) was used with a fixed
buffer last[1024]. outdata is decryption output that is not
null-terminated (CRYPTO_ctr128_encrypt writes newTotalSize bytes). This
could read past outdata and/or overflow last if decrypted size grew.

**Fix**: 

Replace with bounded copy using memcpy and explicit null
termination, limiting bytes copied to remaining space in last and to
sizeof(outdata).
2026-02-15 17:42:01 -08:00
薄景仁
7f7dc99d3e
Urgent! Fix Web Admin Password Check (#1802)
The password check for web admin is reversed, so users can login with
the wrong password. 

Fixes #363, #1216
2026-02-12 21:09:12 -08:00
tyranron
8dc340f9be
Update Debian "trixie" to 20260202 snapshot in Docker image 2026-02-04 17:12:33 +02:00
tyranron
53c405a712
Update Alpine to 3.23.3 version to fix OpenSSL CVEs in Docker image
- CVE-2025-11187
- CVE-2025-15467
- CVE-2025-15468
- CVE-2025-15469
- CVE-2025-66199
- CVE-2025-68160
- CVE-2025-69418
- CVE-2025-69419
- CVE-2025-69420
- CVE-2025-69421
- CVE-2026-22795
- CVE-2026-22796
docker/4.8.0-r1
2026-01-29 12:42:56 +01:00
tyranron
80e20f58f3
Update Debian "trixie" to 20260112 snapshot in Docker image 2026-01-13 13:10:32 +01:00
tyranron
48fb3dd287
Upgrade Docker image to 4.8.0 Coturn version docker/4.8.0-r0 2026-01-06 16:48:21 +01:00
Pavel Punsky
0177bcd373
Update version to 4.8.0 (#1791)
Update version to 4.8.0 
Set new release version to 4.8.0

Contains security fixes and highly recommended to upgrade
4.8.0
2026-01-05 17:35:27 -08:00
tyranron
a7202a72dd
Update Debian "trixie" to 20251229 snapshot in Docker image 2025-12-30 12:33:55 +01:00
Pavel Punsky
11fc465f4b
Merge commit from fork
This returns the code to the state before #1279 that made turn_random() less secure and introduced more secure version with urn_random_number()  (which is actually the same as turn_random() before the change)
2025-12-29 09:05:16 -08:00
Pavel Punsky
bae6bb3aed
Allow faster packet validation on listener threads (#1768)
Add CLI flag to enable early packet validation
Drop packets that do not pass basic STUN command/channel or DTLS parsing

Before this change, no validation on packets were done and they were
passed (through libevent queue) to relay thread pool. Relay thread
would, for a new source, allocate a new SS (18KB) which will only be
released after 1s of no traffic, and then do the validation.

So with old code, invalid packet would have extra:
- Queuing
- Processing on a different thread
- Memory allocation of 18KB

Assuming DDoS attack is spoofing IPs it reduces processing capacity
dramatically.
Testing possible by:
```
hping3 -2 -p 3478 -d 2 -rand-source --flood turn_ip
```

which floods `turn_ip:3478` with packets of size 2 from random sources.
Size 2 is especially bad case - the packet is obviously invalid (too
short) but still goes through a long process of queuing, thread
switching, memory allocation and only then validation (and then memory
cleanup etc). In worst cases, memory is never cleaned up because sources
repeat.
2025-12-29 09:04:25 -08:00
Pavel Punsky
c7936e449b
Fix order of arguments to calloc (#1790)
Proper use of the api: count and then size
This gives a warning on some of the compilers
2025-12-28 11:39:01 -08:00
Pavel Punsky
21ddce65be
Fix crashes while setting socket buffer size (#1789)
Some places in code do not have access to the buffer size which result
in crash which can be seen in tests
This PR removes the call to `set_ioa_socket_buf_size` from those places
(which is redundant anyway)
2025-12-26 21:10:24 -08:00
Pavel Punsky
59921981bb
Implement configurable buffer sizes (#1780)
# Description

Replace the hardcoded buffer sizes inside coturn to make them
configurable for different use cases (low bitrate use cases can save
memory and high bitrate use case can avoid congestion) - based on #1089

Add this feature in both sides (listener and relay connections).

# Tests

For now it is only the automated CI tests.
Confirmed with debugger that buffer sizes are set according to the
arguments.
2025-12-25 14:06:28 -08:00
tyranron
6a0b3a648a
Update Alpine to 3.23.2 version in Docker image docker/4.7.0-r4 2025-12-18 14:44:24 +01:00
dependabot[bot]
15cecc97a2
Upgrade actions/download-artifact from 6 to 7 version (#1785)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-13 01:44:37 +01:00
dependabot[bot]
60ed2e246e
Upgrade actions/upload-artifact from 5 to 6 version (#1784)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-13 01:43:51 +01:00
dependabot[bot]
b7dfa236c1
Upgrade actions/cache from 4 to 5 version (#1783)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-12 12:03:36 +01:00
tyranron
5a6c9f3ce4
Update Debian "trixie" to 20251208 snapshot in Docker image 2025-12-09 12:33:53 +01:00
Pavel Punsky
265d1029e6
Use bool to enable prometheus (#1779)
`turn_params.prometheus` is bool but used as int throughout the code
`turn_params,prometheus_username_labels` is bool but in one place is set
with 1

This PR changes 0 and 1 to false and true accordingly
2025-12-08 08:43:36 -08:00
tyranron
a668d4b4cc
Upgrade Alpine to 3.23 version in Docker image docker/4.7.0-r3 2025-12-04 15:34:15 +01:00
dependabot[bot]
9298847097
Upgrade actions/checkout from 5 to 6 version (#1776)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-21 13:37:27 +01:00
tyranron
60b6e2d816
Update Debian "trixie" to 20251117 snapshot in Docker image 2025-11-18 13:57:46 +01:00
tyranron
e1d3ba8a69
Update Debian "trixie" to 20251103 snapshot in Docker image 2025-11-05 12:04:30 +02:00
dependabot[bot]
5c14404c71
Upgrade actions/upload-artifact from 4 to 5 version (#1771)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-25 10:03:37 +02:00
dependabot[bot]
7cd09efe87
Upgrade actions/download-artifact from 5 to 6 version (#1772)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-25 10:02:45 +02:00
tyranron
bc8d0ca36b
Update Debian "trixie" to 20251020 snapshot in Docker image 2025-10-22 14:28:29 +03:00
tyranron
242467faba
Update Alpine to 3.22.2 version in Docker image to fix CVE-2025-9230, CVE-2025-9231 and CVE-2025-9232 docker/4.7.0-r2 2025-10-09 14:13:50 +03:00
dependabot[bot]
ec5f2bcd83
Upgrade github/codeql-action from 3 to 4 version (#1759)
Additionally:
- fix missing NSIS for Windows on CI
- replace macOS 13 with 26 on CI

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kai Ren <tyranron@gmail.com>
2025-10-08 13:43:16 +02:00
tyranron
e1ce664cbb
Update Debian "trixie" to 20250929 snapshot in Docker image 2025-09-30 14:27:15 +03:00
Pavel Punsky
63447a763a
Fix memory leak using libevent (#1751)
Fixes #1750
2025-09-28 21:00:44 -07:00
redraincatching
b1dddb5f49
addressed possible null pointer dereferences (#1729)
this pr aims to address more static code analyser warnings, specifically
null pointer dereferences. the majority of changes are solely to quieten
the analyser, as `malloc` and `calloc` are unlikely to fail, but this
should at least lead to the code analysis being more readable and
usable.

where functions addressed had existing failure strategies, they were
used, however some functions will now silently fail rather than
attempting to dereference a null pointer. if there is a preferred
solution in these cases, i will be happy to implement it.

---

-
[27](https://github.com/redraincatching/coturn/security/code-scanning/27):
moved use of pointer inside `else` block of null check
-
[42](https://github.com/redraincatching/coturn/security/code-scanning/42):
added early return in case of null pointer
-
[69](https://github.com/redraincatching/coturn/security/code-scanning/69):
added null pointer check after `malloc`
-
[76](https://github.com/redraincatching/coturn/security/code-scanning/76):
added null pointer check after `calloc`
-
[77](https://github.com/redraincatching/coturn/security/code-scanning/77):
added null pointer check to loop guard
-
[82](https://github.com/redraincatching/coturn/security/code-scanning/82):
added null pointer check after `malloc`
-
[83](https://github.com/redraincatching/coturn/security/code-scanning/83):
added null pointer check after `malloc`
-
[84](https://github.com/redraincatching/coturn/security/code-scanning/84):
added null pointer check after `calloc`
-
[85](https://github.com/redraincatching/coturn/security/code-scanning/85):
added null pointer check around pointer use, as done earlier in the same
function
-
[86](https://github.com/redraincatching/coturn/security/code-scanning/86):
added null pointer check after `calloc`
-
[90](https://github.com/redraincatching/coturn/security/code-scanning/90)/[91](https://github.com/redraincatching/coturn/security/code-scanning/91)/[92](https://github.com/redraincatching/coturn/security/code-scanning/92)/[93](https://github.com/redraincatching/coturn/security/code-scanning/93):
added null pointer check to block
-
[94](https://github.com/redraincatching/coturn/security/code-scanning/94)/[95](https://github.com/redraincatching/coturn/security/code-scanning/95):
added null pointer checks after `malloc`
-
[108](https://github.com/redraincatching/coturn/security/code-scanning/108):
added check after `calloc`
-
[114](https://github.com/redraincatching/coturn/security/code-scanning/114):
added check after `memcpy`
-
[129](https://github.com/redraincatching/coturn/security/code-scanning/129):
added check after `calloc`
-
[145](https://github.com/redraincatching/coturn/security/code-scanning/145):
added check to if guard
-
[146](https://github.com/redraincatching/coturn/security/code-scanning/146):
added check to if guard
-
[154](https://github.com/redraincatching/coturn/security/code-scanning/154):
added early exit with error
-
[165](https://github.com/redraincatching/coturn/security/code-scanning/165):
added check after `malloc`
-
[170](https://github.com/redraincatching/coturn/security/code-scanning/170):
added early null return on null pointer
-
[171](https://github.com/redraincatching/coturn/security/code-scanning/171):
added check after `calloc`

---
![You're dereferencing a null
pointer!](https://i.makeagif.com/media/9-29-2015/YwGqu_.gif)
2025-09-11 18:00:38 -07:00
tyranron
0f46392ec1
Update Debian "trixie" to 20250908 snapshot in Docker image 2025-09-09 11:45:29 +03:00
redraincatching
2a9b77bd0b
address possible null pointer dereferences (#1744)
# addressing all remaining code scanning instances of warning C6011,
null pointer dereference

this pr aims to address more static code analyser warnings, specifically
null pointer dereferences. the majority of changes are solely to quieten
the analyser, as `malloc` and `calloc` are unlikely to fail, but this
should at least lead to the code analysis being more readable and
usable.

where functions addressed had existing failure strategies, they were
used, however some functions will now silently fail rather than
attempting to dereference a null pointer. if there is a preferred
solution in these cases, i will be happy to implement it.

---

this is an extension of [this pull
request](https://github.com/coturn/coturn/pull/1729)
2025-09-08 21:18:33 -07:00
Michael Jones
98d91a73cf
Improve const correctness in coturn (#1424)
Marking variables as const when they won't be modified after
initialization helps programmers trying to understand a codebase to
manage the cognative load.

This pull request uses a clang-tidy fixit (Hard to automate, since the
code needs to be temporarily compiled as C++ for it to work) to try to
mechanically apply the const keyword to code where the automated tool
can determine that the variable won't be modified.

I then follow this up with a manual improvement pass to
turnutils_uclient, where I address const correctness of local variables,
as well as do some adjustments to loops and scoping to help with
reducing complexity.

Co-authored-by: redraincatching <redraincatching@disroot.org>
Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2025-09-08 21:14:56 -07:00
Pavel Punsky
0749cd7efd
Update attribute values according to RFC 8656 (#1748)
Source https://datatracker.ietf.org/doc/html/rfc8656#section-18
Now conforms to RFC specification

- ADDITIONAL_ADDRESS_FAMILY (0x8000) - was (0x8032)
- ADDRESS_ERROR_CODE (0x8001) - was (0x8033)

Fixes #1740
2025-09-07 19:34:38 -07:00
Jun Lyu
ce72767375
fixing missing dependencies in Makefile (#1739)
This PR fixes an issue in the Makefile. Specifically, previously, any
modifications of files like src/apps/common/ns_turn_openssl.h would not
trigger a rebuild of build/obj/ns_turn_msg.o. The PR fixes this by
including them as additional dependencies.
2025-09-06 17:46:59 -07:00