🔒 Fix Tenant Isolation Failure in Webhooks and Interactions#6
🔒 Fix Tenant Isolation Failure in Webhooks and Interactions#6CaioIsCoding wants to merge 1 commit intomainfrom
Conversation
…teraction service - Replaced unfiltered `db.query(Tenant).first()` with secure lookups based on Evolution API instance name and sender's WhatsApp JID. - Modified `InteractionService.handle_message` to filter content jobs by the sender's authorized tenant. - Ensured new tenants created via webhooks are correctly associated with their Evolution API instances and admins. - Prevents cross-tenant data access and unauthorized command execution. Co-authored-by: CaioIsCoding <106751132+CaioIsCoding@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
The fix addresses a critical tenant isolation failure where webhooks and user interactions were being associated with the first tenant in the database regardless of the actual sender or instance.
Key changes:
app/api/v1/webhooks.py, theevolution_webhooknow:SocialAccountand filtering by theinstancename from the payload.remote_jidis in theadmin_jidslist.app/services/interaction.py,handle_messagenow:ContentJobwithTenantand filters byTenant.admin_jids.contains([remote_jid]).These changes prevent unauthorized users from viewing or approving content from other tenants.
PR created automatically by Jules for task 8567954283396659769 started by @CaioIsCoding