1438 Commits
Author SHA1 Message Date
Tristan a6f94564f2 fix: use snprintf to prevent stack buffer overflow in REGISTER_SUPER_ACK IPv6 handling (#1251)
sprintf(ip_tmp, "%s:%u", ...) in the REGISTER_SUPER_ACK decoder can
overflow the 48-byte ip_tmp stack buffer when formatting an IPv6
address (up to 45 chars) with a port number, producing up to 52 bytes.

Replace sprintf with snprintf(ip_tmp, sizeof(ip_tmp), ...) so the
output is truncated to the buffer size.
2026-10-17 14:56:56 +02:00
HoneyBunnyQTandClaude Opus 5.5 fdd969b9c7 Remotely triggerable Denial of Service (#1249)
* header_encryption: require a full common header before decrypting

packet_header_decrypt() takes header_len from the decrypted magic and
only checked header_len <= packet_len.  For a packet of another
community (or a made-up one) the value is arbitrary; below 16 the
header_len - 16 argument to speck_ctr() wraps to a huge size_t and the
decryption reads and writes far past packet[].  One crafted UDP datagram
(or ~1 in 2^28 random ones per key) crashes any edge or supernode that
attempts header decryption; a supernode tries its federation key on
every non-plain header.  Require at least the 24-byte common header, as
the encrypt side already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* transform_cc20: decrypt only the ciphertext, not the IV length extra

transop_decode_cc20() passed in_len (iv + ciphertext) as the length of
the ciphertext that follows the iv, so cc20_crypt() read 16 bytes past
the input and wrote 16 past the output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 11:28:41 +02:00
Akhil KoulandAkhil Koul 4831375d6e fix: use lzo1x_decompress_safe to prevent stack buffer overflow (#1245)
Replace lzo1x_decompress() with lzo1x_decompress_safe() in
transop_decode_lzo(). The unsafe variant does not enforce the output
buffer size limit, allowing a crafted compressed payload to overflow
the N2N_PKT_BUF_SIZE (2048 byte) stack buffer in handle_PACKET().

The safe variant (already bundled in src/minilzo.c) validates output
bounds during decompression, preventing the overflow.

The post-decompression size check was ineffective because the overflow
had already occurred before the check executed.

CAN-2026-2035137

Co-authored-by: Akhil Koul <akkoul@amazon.com>
2026-08-05 10:59:21 +02:00
Lars Wallenborn 98738bce4f edge, supernode: allow -t 0 to disable the management UDP port (#1242)
* supernode: allow -t 0 to disable the management port

* supernode: skip mgmt-socket fd_set/fd_isset when disabled

* edge: allow -t 0 to disable the management port

* edge: skip mgmt-socket fd_set/fd_isset when disabled

* docs: document -t 0 to disable the management port
2026-08-05 10:59:03 +02:00
Copilotandlucaderi 829fcd3b9f Update GitHub Actions artifact uploads to v4 to unblock ubuntu-22.04 Linux test job (#1246)
* Initial plan

* ci: upgrade upload-artifact action to v4 in tests workflow

Co-authored-by: lucaderi <4493366+lucaderi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lucaderi <4493366+lucaderi@users.noreply.github.com>
2026-08-05 10:44:46 +02:00
Michael Bommarito 854fbbe01b wire: bound decoded auth.token_size and num_sn to destination sizes (#1243)
decode_buf() verifies that the source packet still holds the requested
number of bytes, but not that the requested length fits the destination
buffer. The REGISTER_SUPER / UNREGISTER_SUPER / REGISTER_SUPER_ACK /
REGISTER_SUPER_NAK decoders read auth.token_size (a 16-bit field) and
num_sn (an 8-bit count) directly from the wire and pass them to
decode_buf() targeting fixed-size destinations: auth.token is
N2N_AUTH_MAX_TOKEN_SIZE (48) bytes, and the REGISTER_SUPER_ACK backup
list is bounded by REG_SUPER_ACK_PAYLOAD_SPACE.

A length field larger than its destination therefore lets a malformed
packet write past the end of the buffer. Validate token_size against
N2N_AUTH_MAX_TOKEN_SIZE and num_sn against REG_SUPER_ACK_PAYLOAD_SPACE
before calling decode_buf(), returning a decode error otherwise. A
conforming peer never sends a larger value, so well-formed traffic is
unaffected.

Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
2026-06-22 06:59:21 +02:00
Copilot dc7324af16 CI: unblock Code Analysers job by migrating deprecated artifact action (#1244)
* Initial plan

* ci: update analyser artifact upload action to v4

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-22 06:58:39 +02:00
Simon Brodeur 31936c8728 Update tuntap_linux.c (#1169)
Let the kernel takes care of assigning the port ID of the netlink socket
2026-03-02 22:38:59 +01:00
dependabot[bot] 2a71590c12 Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows (#1183)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-02 22:38:29 +01:00
Jun Lyu fe5f738174 Fixing missing dependencies in Makefile (#1230) 2026-03-02 22:37:59 +01:00
thomasysliu 682555ffde Update for MINGW windows build (#1232)
Add missing header stdlib.h, iphlpapi.h
Force type casting for CryptGenRandom, setsockopt, strncpy
ifdef for getenv proto type
2026-03-02 22:37:26 +01:00
Simon Brodeur 23e5160fc8 Update tuntap_linux.c (#1169)
Let the kernel takes care of assigning the port ID of the netlink socket
2025-05-02 18:26:25 +02:00
Hamish Coleman fff50a7d80 Ensure the code style is kept 2023-10-24 11:20:13 +01:00
Hamish Coleman d2bafa716d Fix API initialisation to actually ignore invalid packets or passwords 2023-10-24 11:20:13 +01:00
Hamish Coleman c552db6443 Fix last seen edge case 2023-10-24 11:20:13 +01:00
Hamish Coleman beb14c8d70 Dont treat bools as a magic number and simplify negated tests where possible 2023-10-24 11:20:13 +01:00
Hamish Coleman 1a598fa43b Ensure that we initialise the purgeability of peer structures when we allocate them 2023-10-24 11:20:13 +01:00
Hamish Coleman e9659e3b9a Add a last_seen column to n2n-ctl with human readable values 2023-10-24 11:20:13 +01:00
Alfredo Cardigliano 4f54649eeb PR template 2023-10-19 09:32:52 +02:00
Luca Deri cd7b3b4661 Added prerequisite 2023-08-31 08:19:34 +02:00
Hamish Coleman b0d742b3f5 Remove the need for autoconf in the debian package
Continuing to try and simplify the build system, calculate the remaining
two autoconf variables from the existing config.mak.

For the moment, leave a configure and configure.ac file in place to
allow any old build systems to continue to function without errors.
2023-08-30 20:27:14 +01:00
Hamish Coleman 018add0280 Use a simple debian/control Architecture
By switching to the "any" architecture, we no longer need to template
the debian/control file.  This simply claims that the package can be
built on any known debian arch - which we currently think is true - so
it will help future portability.
2023-08-30 20:27:14 +01:00
Hamish Coleman d7eff5313b Add a hack for the github builders 2023-08-30 20:27:14 +01:00
Hamish Coleman 9d4f68fce2 Regenerate packages configure scripts 2023-08-30 20:27:14 +01:00
Hamish Coleman cee0431a61 Work around ubuntu build environment
TODO:
- dont just ignore missing info, have something to fill it in even when
  the require arch binaries are missing
2023-08-30 20:27:14 +01:00
Hamish Coleman f2597e8f42 Install some packages for cross compiling 2023-08-30 20:27:14 +01:00
Hamish Coleman 231f4d9ed0 Remove unneeded debian/files - it is autogenerated 2023-08-30 20:27:14 +01:00
Hamish Coleman 1b862513ff Regenerate packages configure scripts 2023-08-30 20:27:14 +01:00
Hamish Coleman c2f08642c0 Remove unneeded templating of systemd units 2023-08-30 20:27:14 +01:00
Hamish Coleman 50748f210a Remove unneeded templating of debian/rules 2023-08-30 20:27:14 +01:00
Hamish Coleman 0385d4fcbe Automatically generate debian changelog 2023-08-30 20:27:14 +01:00
Hamish Coleman 3cb57e2a6e Use dh_shlibdeps to calculate depends
This may impact builds on Debian 8, but that version has been out of
support for over three years.  I didnt test it, but since using this
helper is the preferred method it may actually help builds on older
versions.
2023-08-30 20:27:14 +01:00
Hamish Coleman ecb869517e Remove static definition from deb package builder 2023-08-30 20:27:14 +01:00
shaxxx 7c107887f4 Fix auto IP tracking 2023-08-27 15:04:39 +01:00
Hamish Coleman f79153166b Concentrate more windows wierdness in one place - allowing proper ordering of crazy defs and includes 2023-08-03 21:40:31 +01:00
Hamish Coleman 65359c7916 Add a missing library function 2023-08-03 21:40:31 +01:00
Hamish Coleman 5514d91976 For some reason, these headers dont work for 64bit - windows is strange 2023-08-03 21:40:31 +01:00
Hamish Coleman 5eaf7fca8b Add windows XP to regular cross-compile tests 2023-08-03 21:40:31 +01:00
Hamish Coleman 567ae8db6b Try to simplify and improve windows objs definitions 2023-08-03 21:40:31 +01:00
Hamish Coleman 3bf584c580 Add tweaks to support windows XP 2023-08-03 21:40:31 +01:00
Hamish Coleman 439939dc7b Simplify tuntap_open by using one function prototype for all OS 2023-08-03 21:40:31 +01:00
Hamish Coleman 6b8ba8aa94 Move the examples to their own directory 2023-07-31 20:56:49 +01:00
Hamish Coleman 6ddaaaa917 Move win32 specific file to the right dir 2023-07-31 20:56:49 +01:00
Hamish Coleman 83078c8104 Simplify win32 build process
When building on win32 systems, simply add the win32 specific functions
to the libn2n.a, which simplifies the commands needed.

By moving the win32 source code into the src directory, the source code
is better consolidated.
2023-07-31 20:56:49 +01:00
Hamish Coleman 6957b16537 Address compiler warning on older gcc 2023-07-06 02:54:36 +08:00
Hamish Coleman 183e0c969a Hack around the "helpful" exe file suffix
If there is a way to turn off the mingw insistence that it will rewrite
the filename it was given in the "-o" options, I have not been able to
find it.  I could easily handle all the moves or renames at the end of
the build process if I could turn off this feature.  Especially since it
means that make often thinks that the file has not been built (the
filename that make knows about is not the file that actually gets built
by the mingw gcc, so the if-newer tests that make applies will always
fail)
2023-07-03 02:51:20 +08:00
Hamish Coleman 84dac6220b Add a cross-compiled 64bit windows build to CI 2023-07-03 02:51:20 +08:00
Hamish Coleman e16911d6ec The arm64 build has now been tested on real hardware 2023-07-03 02:51:20 +08:00
Hamish Coleman 0b662fc0f4 A bunch of hacks to allow builds to understand the stupid windows filenames 2023-07-03 02:51:20 +08:00
Hamish Coleman 4d2e92ac81 Ensure library is included in correct order
It looks to me that the correct way to address this build wrinkle is
simply to add the win32 functions to the libn2n when building a win32
output, then there is no additional magic library juggling required for
the win32 case
2023-07-03 02:51:20 +08:00