Skip to content

2133: Add microphone spoofing media stack + libmicspoofing#25

Open
RankoR wants to merge 8 commits intoGrapheneOS:16-qpr2from
RankoR-GOS:mic-spoofing
Open

2133: Add microphone spoofing media stack + libmicspoofing#25
RankoR wants to merge 8 commits intoGrapheneOS:16-qpr2from
RankoR-GOS:mic-spoofing

Conversation

@RankoR
Copy link
Copy Markdown

@RankoR RankoR commented Mar 5, 2026

Implements GrapheneOS/os-issue-tracker#2133

  • AudioRecord fallback to spoofed source on PERMISSION_DENIED when mic spoofing is enabled for UID
  • AAudio input disables MMAP for spoofed UIDs
  • MediaRecorderClient allows audio source when spoofing is enabled
  • introduces Rust/C FFI libmicspoofing with default/custom WAV source loading, conversion, and safety fallbacks
  • adds instrumentation, native, Rust tests, and fuzzer

Tests:

atest -c \
  MicSpoofingTests \
  MicSpoofingGrantedTests \
  libmicspoofing_rs_test \
  mic_spoofing_tests \
  aaudio_spoofed_test \
  opensles_spoofed_test

Fuzzing:

m mic_spoofing_fuzzer
adb sync data
FUZZ_BIN="$(adb shell 'find /data/fuzz -type f -name mic_spoofing_fuzzer 2>/dev/null | head -n 1' | tr -d '\r')"
adb shell "$FUZZ_BIN -max_total_time=60"

@RankoR
Copy link
Copy Markdown
Author

RankoR commented Mar 5, 2026

  1. There are buffer re-allocations each call in some branches. Due to the nature of the hardened allocator, it's "costlier" than on the default allocator, where its cost is near-zero. However, it's still not too "expensive", and spoofing shouldn't happen too often to affect user-perceived performance. On the other hand, if we pre-allocate a buffer and reuse it, it would make code & memory management more complex, introducing new risks. IMO, this small tradeoff is ok.
  2. As we're using a silent WAV by default, it makes testing more difficult (as tests expect non-zero samples). So there are hacks to replace the default silent file with a non-silent one in tests.

@RankoR RankoR force-pushed the mic-spoofing branch 3 times, most recently from 08a0c72 to cb3a56c Compare March 11, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant