Skip to content

Event Handler Proxy Detection - JS Proxy #296

@alpgul

Description

@alpgul

Description

This test scenario is a security control mechanism that detects proxy manipulation of event handlers. The aim is to distinguish real user interactions from artificial/bot interactions. EventTarget.prototype.addEventListener detects unauthorized modification of events.

Test Code

document.addEventListener('click', (event) => {
    try {
        const proxyEvent = new Proxy(event, {});
        Object.getOwnPropertyDescriptor(Event.prototype, "type").get.call(event);
        if (proxyEvent.isTrusted === false) {
            console.log("Potential bot/proxy attempt detected");
        }
    } catch (error) {
        // Error handling and anti-bot control mechanism
        if (error instanceof TypeError && error.message.includes("Illegal invocation")) {
            console.log("[E]Potential bot/proxy attempt detected");
            // Anti-bot action
        }
    }
});
document.dispatchEvent(new Event("click"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions