22 Commits

Author SHA1 Message Date
heyaim
b9bf303d9a Verify replayed messages from peers that have left the mesh
A REQUEST_SYNC reply can carry a message from a peer that has left, on
LEAVE or after three minutes of silence. Normally the neighbor re-serves
that peer's announcement first, which restores the signing key. When the
key is not restored, the message arrives with no key on file and the
signature check rejects it. That happens in two cases. An iOS neighbor
that relaunched serves messages restored from disk, and that archive
holds no announcements. An Android neighbor that missed the LEAVE keeps
serving the peer for about three minutes while the receiving device
rejects the re-served announcement as a duplicate. iOS keeps a message
from a sender that has left when it has verified that sender before, by
falling back to its persisted identity. Android persists the signing key
for every peer that completed the authenticated peer-state exchange, and
the message path did not read it. This addresses the first bullet of
#622.

The signature check falls back to the persisted signing key when the
live registry has none, found by peer ID directly since a peer ID is the
prefix of its own fingerprint. The broadcast handler delivers a message
from a sender that has left under the cached nickname or the peer ID. A
message from a sender that has left is not archived, and nothing the
LEAVE purge removed re-enters the archive. Messages from present peers
and the receiving device's own broadcasts are archived as before. A live
key is always preferred, a sender with no key on file is rejected as
before, and a registry entry with an unverified nickname is dropped as
before. Receive-side only.

Seventeen tests across the security manager, the message handler, the
coordinator, the secure store and the sync archive.
2026-09-02 23:54:15 -05:00
callebtc
cbc59aaf8b feat(voice): add live push-to-talk 2026-07-31 17:40:37 +02:00
callebtc
c76c233aae handshake robustness 2026-07-27 21:46:24 +02:00
callebtc
6dff0844bb revert noise 2026-07-27 18:44:49 +02:00
callebtc
bc49c71ea0
security: stop logging Noise key material, reduce noisy logging app-wide (#775)
C1 from security review: SymmetricState/HandshakeState logged raw X25519
shared secrets, chaining keys, and handshake hashes in hex to logcat on
every handshake, in release builds. A logcat transcript of a handshake
allowed full session decryption. Both classes no longer log at all.

Also reduces excessive logging across the app (~50% fewer log calls in
the noisiest files):

- NoiseSession emits one line per completed handshake; per-message
  encrypt/decrypt and per-handshake-step debug logs removed
- Removes all content/key logging: decrypted DM content, file names,
  payload hex dumps, pubkeys, event IDs, lat/lon, peer IPs, arti log
  forwarding
- Collapses multi-line banner/emoji log sequences into single factual
  lifecycle lines (connect/disconnect, relay/Tor state transitions)
- Keeps security-relevant warnings (signature failures, replay
  detection, key mismatches, panic wipe) in compact form

No logic changes. Includes the full security review report in
docs/security-review-jul-27.md.
2026-07-27 10:33:29 +02:00
jack
84b24e347f
Bind Noise sessions to claimed peer identities (#730)
* Bind Noise sessions to claimed peer identities

* Make Wi-Fi peer rebinding atomic

* Migrate private media without silent downgrades (#728)

* Migrate private media without silent downgrades

* Accept prerelease private media payloads

* Authenticate private media capability per Noise session

* updates

---------

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
Co-authored-by: jack <jack@deck.local>
Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>

* Authenticate BLE links before peer binding (#749)

* Authenticate BLE links before peer binding

* Fix BLE link authentication races

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>

* Use canonical Maven repository for Robolectric

---------

Co-authored-by: jack <jack@deck.local>
Co-authored-by: jack <jackjackbits@users.noreply.github.com>
Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
Co-authored-by: a1denvalu3 <43107113+a1denvalu3@users.noreply.github.com>
2026-07-26 23:29:57 +02:00
callebtc
171483a1da
drop duplicate announces based on TTL (#558) 2026-01-05 16:41:17 +07:00
callebtc
95385daaf9
verift signature only for ANNOUNCE, MESSAGE, and FILE_TRANSFER like ios (#552) 2026-01-05 11:22:06 +07:00
callebtc
55b2d68def
Enforce mandatory packet signature verification (#546)
* security: enforce mandatory packet signature verification

* tests: add comprehensive unit tests for packet signature verification
2026-01-04 18:47:24 +07:00
callebtc
282ac0fe5a
Fix: do not reject empty packets that arent message type (#510)
* do not reject empty packets that arent message type

* leave message with empty byte array

* clean up comments
2025-11-03 20:37:31 +01:00
callebtc
a4ce8cc979
better tracking of first announce seen (#502) 2025-10-30 00:39:24 +01:00
callebtc
1486121b77
Extract constants (#469)
* extract constants

* refactor constants
2025-10-12 20:59:37 +02:00
callebtc
1178fc254a
remove the noise handshake if peer goes offline (#435) 2025-09-15 15:33:39 +02:00
callebtc
73c91b9509
Plumtree sync (#393)
* wip plumtree

* sync works

* fix logging

* ttl to 0

* fix send packet to one peer

* spec

* wip GCS instead of bloom

* remove bloom filter remainders

* clean

* prune old announcements

* remove announcements from sync after LEAVE

* sync after 1 second

* pruning

* track own announcement and prune messages without announcements

* fix pruning

* getGcsMaxFilterBytes default value 400 bytes

* parameters
2025-09-14 03:32:10 +02:00
callebtc
33b5814b7a
Sign mesh message (#353)
* sign BLE packets

* fix x
2025-08-30 12:45:36 +02:00
callebtc
9795e2ce8a
Changes bitchat protocol (#265)
* create payload

* compiles and can send messages

* identityannouncement

* DMs work, read receipt not sent yet

* works

* delete old code

* simplify

* working

* fragment wip

* compression wip

* use zlib compression

* clean

* nice

* mesh

* remove comments
2025-08-18 21:16:27 +02:00
callebtc
4cb5932fd0
improve identity announcements (#198)
* improve identity announcements

* touches

* signing noise id

* panic mode delete signing key
2025-07-31 06:26:41 +02:00
callebtc
534be7e613
Refactor fingerprint manager (#185)
* centralized fingerprint manager

* centralized fingerprintmanager

* update fingerprint only if no collision
2025-07-25 15:43:19 +02:00
callebtc
c3c395832c
Implement Noise XX Handshake Protocol for Direct Messages (#180)
* noise

* works?

* noise

* temporary

* better

* wip: use subnet

* better

* barely working

* werk

* subnet

* fix peer ID

* 8 byte peer ID

* wip noise

* wip fixes for noise

* std lib for noise

* noise handshake one step further

* buffers

* use fork

* fix imports

* simplify counter

* remove trash

* hashing

* no prologue

* nice

* wip, use noise encryption

* peer ID hex

* simplify session manager

* heavy logging

* use singleton

* Fix Noise session race condition with elegant per-peer actor serialization

- Use Kotlin coroutine actors for per-peer packet processing
- Each peer gets dedicated actor that processes packets sequentially
- Eliminates race conditions in session management without complex locking
- Single surgical change in PacketProcessor - minimal, maintainable
- Leverages Kotlin's native concurrency primitives

* decrypt correctly

* iniator works now

* clean code and fix signature to null

* better

* no signature in private message

* small fixes

* refactor ack

* refactor but untested

* messages working

* wip ack

* wip fix ack

* more logging

* pending tracker

* keep pending connections on errors

* less logging

* refactor model

* refactor frombinarydata

* idendityannouncement refactor and update to new binary protocol

* fix keys

* refix keys

* dms work

* revert to mainnet

* do not change bluetooth adapter name

* keep code but uncomment

* clean up comments

* cleanup comments
2025-07-24 12:01:46 +02:00
GUVWAF
d1085fde0b Cheap routing optimizations
- Don't relay back to sender or relayer
- Only send to connected device if recipientID matches one
- Don't relay our own ACK/read receipt
2025-07-12 13:18:09 +02:00
callebtc
e58cf4fd0d fix null pointer 2025-07-12 12:53:01 +02:00
callebtc
9ba8dca82a seems to work 2025-07-08 23:38:35 +02:00