FluidVoice icon indicating copy to clipboard operation
FluidVoice copied to clipboard

Security Assessment: OWASP Mobile Top 10 Mapping & Recommendations

Open faesel opened this issue 7 months ago • 2 comments

Security Assessment — OWASP Mobile Top 10 (2024) Mapping

Thank you for building FluidVoice — it is an excellent open-source dictation tool with a strong local-first design. This issue is a constructive security assessment mapped against the OWASP Mobile Top 10 (2024) to help strengthen the project's security posture.


Summary of Findings

OWASP Category Finding Severity
M2 — Inadequate Supply Chain Security Unpinned dependencies in Package.swift 🟠 Medium
M2 — Inadequate Supply Chain Security No integrity verification for downloaded ML models 🟠 Medium
M6 — Inadequate Privacy Controls Analytics (PostHog) enabled by default (opt-out) 🟡 Low
M7 — Insufficient Binary Protections disable-library-validation entitlement allows unsigned dylib loading 🔴 High
M8 — Security Misconfiguration No App Sandbox entitlement 🔴 High
M9 — Insecure Data Storage Transcription history (raw text) stored in UserDefaults (unencrypted plist) 🟠 Medium
M9 — Insecure Data Storage Debug builds log API request/response payloads 🟡 Low

Detailed Findings

🔴 M7 — Insufficient Binary Protections: disable-library-validation

File: Fluid.entitlements

<key>com.apple.security.cs.disable-library-validation</key>
<true/>

This entitlement disables macOS's library validation, allowing any dylib (including unsigned or maliciously modified ones) to be loaded into the FluidVoice process at runtime. Combined with the absence of App Sandbox, this significantly increases the attack surface for code injection.

Recommendation: Remove this entitlement if possible. If it is required for a specific third-party framework (e.g., loading CoreML models or SwiftWhisper), document the justification clearly and consider requesting a more scoped exception from Apple instead.


🔴 M8 — Security Misconfiguration: No App Sandbox

File: Fluid.entitlements

The entitlements file does not include com.apple.security.app-sandbox. Without sandboxing, the app has unrestricted access to the filesystem, network, and other system resources. This means that if the process is compromised (e.g., via the library validation issue above), the attacker inherits full user-level access.

Recommendation: Enable App Sandbox with only the entitlements the app actually needs:

  • com.apple.security.device.microphone (audio capture)
  • com.apple.security.network.client (for AI provider API calls and model downloads)
  • com.apple.security.files.user-selected.read-write (if file access is needed)
  • com.apple.security.automation.apple-events (already present, for typing simulation)

🟠 M2 — Inadequate Supply Chain Security: Unpinned Dependencies

File: Package.swift

.package(url: "https://github.com/altic-dev/FluidAudio.git", branch: "B/cohere-coreml-asr"),
.package(url: "https://github.com/altic-dev/DynamicNotchKit.git", branch: "main"),
.package(url: "https://github.com/exPHAT/SwiftWhisper.git", branch: "master"),

Three dependencies are pinned to branches rather than specific version tags or commit SHAs. This means a force-push or compromise of any of these repos would silently alter the code pulled into FluidVoice builds.

Recommendation:

  • Pin all dependencies to specific version tags or commit SHAs
  • Consider using Package.resolved as a lockfile and checking it into CI with integrity verification
  • For dependencies you own (FluidAudio, DynamicNotchKit), publish tagged releases

🟠 M2 — Inadequate Supply Chain Security: No Model Integrity Verification

File: Sources/Fluid/Networking/ModelDownloader.swift

The HuggingFaceModelDownloader downloads ML model files from HuggingFace over HTTPS but performs no checksum or hash verification after download. If a model file were tampered with (e.g., via a compromised HuggingFace repo or MITM on a misconfigured network), the app would load it without detection.

Recommendation:

  • Maintain a manifest of expected SHA-256 hashes for each model file
  • Verify the hash of each downloaded file before loading it into CoreML
  • Consider signing model files and verifying signatures

🟠 M9 — Insecure Data Storage: Transcription History in UserDefaults

File: Sources/Fluid/Persistence/TranscriptionHistoryStore.swift

Transcription history — including rawText, processedText, appName, and windowTitle — is stored in UserDefaults, which persists as an unencrypted plist file on disk. Any process running as the same user can read this data.

private func saveEntries() {
    if let encoded = try? JSONEncoder().encode(entries) {
        self.defaults.set(encoded, forKey: Keys.transcriptionHistory)
    }
}

Recommendation:

  • Move transcription history to an encrypted store (e.g., encrypted SQLite via SQLCipher, or store in the Keychain if the data volume is small)
  • At minimum, consider storing in the app's Application Support directory with appropriate file permissions, rather than UserDefaults
  • Provide users an option to disable history persistence entirely

🟡 M6 — Inadequate Privacy Controls: Analytics Opt-Out by Default

Files: Sources/Fluid/Analytics/AnalyticsService.swift, AnalyticsConfig.swift

Analytics via PostHog are enabled by default and send telemetry to eu.i.posthog.com including hardware model, chip family, CPU brand, app version, and feature usage flags. While transcription content is not sent, this is an opt-out rather than opt-in model.

Recommendation:

  • Consider making analytics opt-in (especially important for a privacy-focused dictation tool)
  • Show a clear first-run prompt explaining what is collected and allowing the user to choose
  • Document the full list of collected properties in the README (partially done already — thank you)

🟡 M9 — Insecure Data Storage: Debug Logging of Sensitive Data

File: Sources/Fluid/Networking/AIProvider.swift, FunctionCallingProvider.swift

In debug builds, API request and response payloads are logged via DebugLogger, which may include user transcription text sent to AI providers for enhancement:

#if DEBUG
DebugLogger.shared.debug("AI Request to: \(request.url?.absoluteString ?? \"unknown\")", source: "AIProvider")
#endif

While this is gated behind #if DEBUG, if debug builds are distributed (e.g., to beta testers via TestFlight or direct .app distribution), this data could be exposed in system logs.

Recommendation:

  • Ensure debug builds are never distributed externally
  • Consider redacting or truncating user content in log statements even in debug mode
  • Add a log-level configuration to control verbosity

Additional Recommendations

  1. Add a SECURITY.md with a vulnerability disclosure policy so security researchers know how to report issues responsibly
  2. Add Dependabot or similar for automated dependency vulnerability scanning
  3. Consider adding CodeQL or similar SAST to the GitHub Actions CI pipeline

Acknowledgement

This assessment was performed as a constructive review to help improve the project. FluidVoice already does several things well from a security perspective:

  • ✅ API keys stored in macOS Keychain (not plain text)
  • ✅ Local-first speech recognition (no audio sent to cloud by default)
  • ✅ Authorization headers correctly omitted for local endpoints
  • ✅ Analytics uses anonymous UUID with no content data
  • ✅ SwiftLint strict mode in CI

Thank you for your work on this project.

faesel avatar Apr 24 '26 16:04 faesel

Additional Recommendation: Enable GitHub Security & Code Quality Features

I noticed the repository doesn't appear to have GitHub's built-in security and code quality features enabled. These are free for public repositories and would significantly strengthen the project's security posture with minimal effort.

Recommended Features to Enable

1. Dependabot Alerts & Security Updates

Settings → Security → Code security → Dependabot

  • Dependabot alerts — Automatically notifies you when a dependency has a known CVE
  • Dependabot security updates — Automatically opens PRs to bump vulnerable dependencies
  • Dependabot version updates — Keeps dependencies up to date (add a .github/dependabot.yml)

This is especially important given the unpinned branch: "main" dependencies flagged in the main issue.

2. Code Scanning (CodeQL)

Settings → Security → Code security → Code scanning

  • GitHub's free SAST (Static Application Security Testing) tool
  • Supports Swift and can catch common vulnerability patterns (injection, data exposure, etc.)
  • Runs automatically on PRs and pushes
  • Can be added as a GitHub Actions workflow:
# .github/workflows/codeql.yml
name: CodeQL Analysis
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  schedule:
    - cron: "0 6 * * 1"  # Weekly Monday scan

jobs:
  analyze:
    name: Analyze
    runs-on: macos-latest
    permissions:
      security-events: write
    strategy:
      matrix:
        language: [swift]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        with:
          languages: ${{ matrix.language }}
      - name: Build
        run: |
          xcodebuild build \
            -project Fluid.xcodeproj \
            -scheme Fluid \
            -destination 'platform=macOS,arch=arm64' \
            CODE_SIGN_IDENTITY="" \
            CODE_SIGNING_REQUIRED=NO \
            CODE_SIGNING_ALLOWED=NO
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v3

3. Secret Scanning

Settings → Security → Code security → Secret scanning

  • Detects accidentally committed API keys, tokens, and credentials
  • Supports push protection to block secrets from being pushed in the first place
  • Critical given that the app handles AI provider API keys (OpenAI, Groq, etc.)

4. Private Vulnerability Reporting

Settings → Security → Code security → Private vulnerability reporting

  • Allows security researchers to report vulnerabilities privately rather than opening a public issue
  • Essential companion to the SECURITY.md file recommended in the main issue

How to Enable

All of these can be turned on in one go:

  1. Go to Settings → Code security (or the repo's Security tab → Overview)
  2. Click Enable for each feature
  3. For CodeQL, add the workflow file above to .github/workflows/

These features are entirely free for public repos and most take just a single click to enable. Together with the findings in the main issue, they would give FluidVoice a much stronger security foundation. 🙏

faesel avatar Apr 24 '26 16:04 faesel

Thanks for putting it here. Will definitely take a look in a bit when I get more time :)

altic-dev avatar May 02 '26 09:05 altic-dev