Inspiration

The inspiration behind DeepfakeShield came from a growing security problem: what happens when the voice authorizing a corporate payment is no longer trustworthy?

AI-generated voice impersonation can make fraudulent payment instructions sound convincing. In corporate treasury operations, a single mistaken authorization can result in significant financial loss.

I realized that relying only on a deepfake detection model would not be enough. Even a sophisticated detector can produce false positives or false negatives. The financial system itself needs additional layers of protection.

That led me to build DeepfakeShield: a security layer designed to verify suspicious voice instructions and protect corporate payouts before money moves.

What it does

DeepfakeShield is an AI-assisted treasury security prototype integrated with the PayPal Payouts API.

It combines multiple security mechanisms:

  • Voice-risk screening: Analyzes audio using spectral features, signal quality measurements and replay detection.
  • AI Risk Reviewer Assistant: Uses Google's Gemini API to provide human reviewers with explanations of suspicious audio measurements.
  • Human-in-the-loop review: Allows an independent Risk Reviewer to inspect challenged audio and record an authorized decision.
  • Dual-officer approval: Requires two independent Treasury Officer approvals before payout execution.
  • Database-enforced security: PostgreSQL 18 validates critical security conditions and prevents unauthorized payout finalization.
  • Protected payout execution: Uses encrypted payout snapshots, cryptographic attestation and an idempotent transactional outbox connected to PayPal.

The central idea is simple: an audio classification or AI-generated explanation must never be enough to authorize a financial transaction.

How we built it

I built DeepfakeShield using Python, FastAPI, PostgreSQL 18, JavaScript and the PayPal Payouts API.

The audio pipeline uses NumPy and SciPy to calculate spectral flatness, high-frequency energy ratios and WADA SNR measurements. SHA-256 hashes and acoustic fingerprints help identify repeated audio.

For additional assistance, I implemented the AI Risk Reviewer Assistant using Google's official Gemini API and the google-genai SDK. It receives sanitized audio-analysis metadata and generates an advisory explanation for authorized reviewers. It does not receive raw audio or beneficiary personal information, and it cannot change risk classifications or approve payments.

The backend uses cryptographic controls including AES-256-GCM, ECDSA P-256 and HMAC-SHA256. PostgreSQL SECURITY DEFINER functions enforce important payout and review conditions independently of the application layer.

We also integrated PayPal OAuth 2.0 and the Payouts API, with both Sandbox API and Simulator modes.

The project includes automated GitHub Actions CI with an isolated PostgreSQL 18 service. The V10.1.5 verification suite passed 55 automated tests, and the additional AI assistant tests were included in the subsequent successful CI run.

Challenges we ran into

One of the biggest challenges was making sure that security did not depend entirely on the audio detection result.

Real human recordings sometimes received CHALLENGE / NEEDS_REVIEW classifications from our heuristic audio analyzer. Instead of lowering detection thresholds simply to approve recordings, we implemented an independent human-review workflow.

Another challenge was enforcing security at the database level. Application-level checks alone are not sufficient for protecting financial transactions, so we implemented PostgreSQL roles, restricted permissions, stored functions and append-only review records.

We also faced challenges with cryptographic key management, multi-process signing-key consistency, PayPal API error handling, and database migration compatibility.

Integrating the Gemini assistant required an additional boundary: AI could explain evidence, but it could never make the financial decision.

Accomplishments that we're proud of

  • Built a complete treasury security architecture connecting voice-risk assessment with financial payout controls.
  • Implemented an independent, append-only audio-risk review workflow.
  • Added database-enforced payout finalization gates in PostgreSQL 18.
  • Implemented two-person Treasury approval architecture using P-256 cryptographic assertions.
  • Integrated PayPal Sandbox OAuth connectivity and Payouts API architecture.
  • Built the Gemini-powered AI Risk Reviewer Assistant with privacy-focused, advisory-only behavior.
  • Implemented an idempotent transactional outbox and reconciliation architecture.
  • Published the project as an open-source MIT-licensed GitHub repository.
  • Established automated PostgreSQL-backed GitHub Actions verification.

Our biggest accomplishment is bringing audio-risk analysis, human governance, cryptography, database security and payment execution into one unified architecture.

What we learned

This project taught me that AI security is not just about building a more accurate model.

A reliable financial system needs separation of responsibilities, independent verification, secure state transitions and carefully controlled execution.

I also learned how to design fail-closed database functions, manage cryptographic keys, build resilient payment integrations, work with PostgreSQL security boundaries, and use generative AI as a support tool without giving it decision-making authority.

Most importantly, I learned that a system should remain secure even when one of its components makes a mistake.

What's next for DeepfakeShield for PayPal

DeepfakeShield is currently an engineering prototype, not a production-ready financial security system.

The next steps include:

  • Integrating and validating a trained neural anti-spoofing model such as AASIST or RawNet2.
  • Completing browser-native hardware-backed WebAuthn authentication.
  • Moving cryptographic key management to a managed KMS or HSM.
  • Replacing the local audio replay registry with distributed storage.
  • Completing a controlled end-to-end PayPal Sandbox payout and reconciliation demonstration.
  • Further validating the system under real-world operating conditions.

Our long-term vision is to make corporate payment authorization more resilient against voice impersonation and unauthorized instructions.

DeepfakeShield — Secure the Decision Before the Money Moves.

Built With

Share this project:

Updates

Submission history