Commit Graph
7 Commits
Author SHA1 Message Date
Pavel Punsky cb701a47b4 Add fuzz coverage for integrity helpers (#1888) 2026-04-30 22:32:50 -07:00
Pavel Punsky 247118d1b4 Add deterministic challenge-response builder to FuzzStun (#1886)
stun_is_challenge_response_str in src/client/ns_turn_msg.c only descends
into its three inner stun_attr_get_first_by_type_str calls when the
input is an error response with err_code 401 or 438 *and* a REALM
attribute *and* a NONCE attribute. The OAuth branch additionally
requires STUN_ATTRIBUTE_THIRD_PARTY_AUTHORIZATION.

The fuzzer-driven path in harness_attr_iter calls the predicate every
iteration but the conjunction of conditions is too specific for
libFuzzer to discover from binary mutation alone — OSS-Fuzz introspector
flags 9 unreached callsites on
stun_attr_get_first_by_type_str gated on this function.

Add harness_challenge_response_builder that constructs six deterministic
message variants on every iteration and runs each through the predicate:

  - 401 with REALM + NONCE                      (canonical success)
  - 401 with REALM + NONCE + THIRD-PARTY-AUTH   (OAuth branch)
  - 438 with REALM + NONCE                      (438 disjunct)
  - 401 with REALM only                         (NONCE-missing path)
  - 401 with no REALM                           (REALM-missing path)
  - 400 with REALM + NONCE                      (wrong err_code path)

Each variant runs once with a non-NULL oauth pointer and once with NULL
to cover both branches of the optional output. Realm / nonce /
server-name lengths and the transaction id are derived from fuzz bytes
so iterations stay meaningfully distinct.

Verified by stand-alone harness:
  - 401+REALM+NONCE returns true with attrs copied out, oauth=false
- 401+REALM+NONCE+TPA returns true with oauth=true and server_name
populated — confirming all three inner get_first_by_type_str callsites
and the OAuth disjunct are now exercised.
2026-04-28 14:30:25 -07:00
Pavel Punsky c8b3dd6513 Merge 10 fuzz targets into FuzzStun and FuzzStunClient via dispatcher (#1873)
Upstream OSS-Fuzz build recipe
(google/oss-fuzz/projects/coturn/build.sh) only copies two fuzzer
binaries -- FuzzStun and FuzzStunClient -- and their seed corpora into
$OUT. The eight additional fuzz targets added later never ran on
oss-fuzz.com, which is why the introspector profile reports "fuzzer no
longer available" for them.

Rather than patching the Google-owned build recipe, fold all fuzzers
into the two binaries OSS-Fuzz actually ships. Each target now begins
with a single-byte selector (Data[0] mod 5) that dispatches to one of
five sub-harnesses:

  FuzzStun        - integrity (SHA1/multi-SHA), attr_iter, attr_add,
                    old_stun
  FuzzStunClient  - stun_client, channel_data, addr_codec, oauth_token,
                    oauth_roundtrip

No upstream OSS-Fuzz changes are required.
2026-04-19 13:00:19 -07:00
Pavel Punsky 2342119db0 Add more fuzzing scenarios (#1857) 2026-04-11 18:02:08 -07:00
Michael Jones da332ed9e7 Add the InsertBraces command for clang-format to ensure that all conditionals always have braces (#1408)
- Why? Because code where conditionals lack braces is much harder to read, and prone to indentation confusion.
- How? Just added an extra flag to .clang-format and re-ran clang-format on all the files.

I also moved .clang-format up to the top level of the repo so that it can be applied to the fuzz targets as well.
2024-01-27 16:38:40 -08:00
Gustavo GarciaandPavel Punsky d9108a4b54 Add clang format rules and checks (#935)
I would like to get feedback on this and see if people is confortable
with these clang rules.

Right now is using the "llvm" style increasing the line length from 80
to 120 given that coturn is using long lines often.

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2022-11-06 22:05:17 +01:00
Arjun dda0c99759 fuzzing support (#982)
Adding fuzzing to finding memory-corruption-related bugs.

Hello coturn team,
Can you check this pr harness suite for creating harnesses and compiling
harnesses?
Any other thoughts on adding a new interface for fuzzing support ?


Signed-off-by: 0x34d <ajsinghyadav00@gmail.com>

Signed-off-by: 0x34d <ajsinghyadav00@gmail.com>
2022-10-24 22:01:58 +02:00