{
    "title": "IDOR (insecure direct object reference)",
    "seo_title": "IDOR: definition, example and prevention",
    "h1": "IDOR (insecure direct object reference)",
    "description": "IDOR explained: how a single altered ID exposes other users' data, and how to fix it in WordPress with current_user_can and permission callbacks.",
    "lead": "An IDOR (insecure direct object reference) vulnerability lets someone access another user's data simply by changing an identifier in a request, such as an order number in the URL, because the application doesn't check that the requested object actually belongs to the logged-in user.",
    "language": "en",
    "locale": "en-US",
    "type": "definition",
    "url": "https://www.wp-feint.com/glossary/idor/",
    "canonical": "https://www.wp-feint.com/glossary/idor/",
    "markdown": "https://www.wp-feint.com/glossary/idor/index.md",
    "json": "https://www.wp-feint.com/glossary/idor/index.json",
    "published": "2026-10-28T08:00:00+00:00",
    "modified": "2026-11-22T12:07:39+00:00",
    "site": {
        "name": "WP Feint",
        "url": "https://www.wp-feint.com/"
    },
    "translations": [
        {
            "language": "en",
            "hreflang": "en-US",
            "title": "IDOR (insecure direct object reference)",
            "url": "https://www.wp-feint.com/glossary/idor/",
            "markdown": "https://www.wp-feint.com/glossary/idor/index.md",
            "json": "https://www.wp-feint.com/glossary/idor/index.json"
        },
        {
            "language": "fr",
            "hreflang": "fr-FR",
            "title": "IDOR",
            "url": "https://www.wp-feint.com/fr/definitions/idor/",
            "markdown": "https://www.wp-feint.com/fr/definitions/idor/index.md",
            "json": "https://www.wp-feint.com/fr/definitions/idor/index.json"
        },
        {
            "language": "es",
            "hreflang": "es-ES",
            "title": "IDOR",
            "url": "https://www.wp-feint.com/es/glosario/idor/",
            "markdown": "https://www.wp-feint.com/es/glosario/idor/index.md",
            "json": "https://www.wp-feint.com/es/glosario/idor/index.json"
        },
        {
            "language": "de",
            "hreflang": "de-DE",
            "title": "IDOR (Insecure Direct Object Reference)",
            "url": "https://www.wp-feint.com/de/glossar/idor/",
            "markdown": "https://www.wp-feint.com/de/glossar/idor/index.md",
            "json": "https://www.wp-feint.com/de/glossar/idor/index.json"
        },
        {
            "language": "it",
            "hreflang": "it-IT",
            "title": "IDOR",
            "url": "https://www.wp-feint.com/it/glossario/idor/",
            "markdown": "https://www.wp-feint.com/it/glossario/idor/index.md",
            "json": "https://www.wp-feint.com/it/glossario/idor/index.json"
        },
        {
            "language": "pt",
            "hreflang": "pt-BR",
            "title": "IDOR",
            "url": "https://www.wp-feint.com/pt/glossario/idor/",
            "markdown": "https://www.wp-feint.com/pt/glossario/idor/index.md",
            "json": "https://www.wp-feint.com/pt/glossario/idor/index.json"
        },
        {
            "language": "nl",
            "hreflang": "nl-NL",
            "title": "IDOR (insecure direct object reference)",
            "url": "https://www.wp-feint.com/nl/woordenlijst/idor/",
            "markdown": "https://www.wp-feint.com/nl/woordenlijst/idor/index.md",
            "json": "https://www.wp-feint.com/nl/woordenlijst/idor/index.json"
        }
    ],
    "headings": [
        {
            "level": 1,
            "text": "IDOR (insecure direct object reference)"
        },
        {
            "level": 2,
            "text": "How an IDOR vulnerability works"
        },
        {
            "level": 2,
            "text": "How to prevent it"
        },
        {
            "level": 2,
            "text": "For WordPress"
        }
    ],
    "body": "The “object” can be an order, an invoice, a profile, a file or a message; the “reference” is the identifier that points to it in the URL, a form or an API request. According to OWASP, the flaw comes from a missing access control check: the application verifies that the user is logged in, but not that they are allowed to view *that particular* object.\n\n## How an IDOR vulnerability works\n\nThe attack requires no special tools. A logged-in customer views their invoice at `/my-account/invoice/?id=1057`. They replace 1057 with 1042, and the site displays another customer's invoice, with that person's name and address. The same scenario shows up in an API route (`/wp-json/shop/v1/orders/1042`), an attachment download or a delete action.\n\n![Four-step IDOR scenario: customer A opens their invoice with ID 1042, customer B, logged in to their own account, replaces their ID 1057 with 1042, the site returns the invoice because it only checks that B is logged in, and the fix is to compare the object's owner with the logged-in user on every request](https://www.wp-feint.com/media/2026/10/idor-flux-en.webp)\n\nIt is the most common form of horizontal [privilege escalation](https://www.wp-feint.com/glossary/privilege-escalation/): the attacker doesn't move up in rank, they access the data of a user at the same level. MITRE classifies it as CWE-639 (“Authorization Bypass Through User-Controlled Key”) and OWASP API Security calls it BOLA (Broken Object Level Authorization). In the OWASP Top 10, it falls under category A01, Broken Access Control, which explicitly mentions viewing or editing someone else's account by providing its identifier.\n\n*Video: “Insecure Direct Object Reference (IDOR) Explained” (PwnFunction)*\n\n## How to prevent it\n\n- **Check every object**: on each request, compare the owner of the requested object with the logged-in user, on the server side.\n- **Only search within what belongs to the user**: a query like “the current user's orders whose ID is X” will never return someone else's.\n- **Avoid exposing the identifier** when it isn't needed: for “my profile,” the user can be derived from the session.\n- **Don't rely on random identifiers**: they make guessing harder, but OWASP points out that they don't replace access control.\n\n## For WordPress\n\nWordPress provides “meta” capabilities that check permission on a specific object. `current_user_can( 'edit_post', $post_id )` doesn't just ask “can this user edit posts?” but “can they edit *this* post?”, taking the author and status into account:\n\n```\n$post_id = absint( $_POST['post_id'] ?? 0 );\nif ( ! current_user_can( 'edit_post', $post_id ) ) {\n    wp_send_json_error( null, 403 );\n}\n```\n\nFor a plugin's own data (orders, bookings, private files), you have to write this check yourself, for example by comparing the stored author with `get_current_user_id()`. In the REST API, this check belongs in the route's `permission_callback`. Two misconceptions come up often: a valid [nonce](https://www.wp-feint.com/glossary/nonce/) proves the request really comes from the site and protects against [request forgery](https://www.wp-feint.com/glossary/csrf/), not that the user is allowed to access the object; and hiding a link in the interface doesn't stop anyone from calling the URL directly.\n\nTo test a plugin, create two accounts with the same role and try to open one account's objects from the other. Access control flaws are among the most frequent in plugins, as [the statistics on plugin vulnerabilities](https://www.wp-feint.com/wordpress-plugin-vulnerabilities-statistics/) show; [our article on the REST API](https://www.wp-feint.com/wordpress-rest-api-security/) helps you spot what your site exposes publicly, and the one on roles and capabilities helps you limit what each account can reach.\n\n## Related terms\n\n- [Privilege escalation](https://www.wp-feint.com/glossary/privilege-escalation/)\n- [Nonce](https://www.wp-feint.com/glossary/nonce/)\n- [CSRF (cross-site request forgery)](https://www.wp-feint.com/glossary/csrf/)\n- [SQL injection](https://www.wp-feint.com/glossary/sql-injection/)\n\n\n## Sources\n\n- [OWASP Cheat Sheet Series : Insecure Direct Object Reference Prevention](https://cheatsheetseries.owasp.org/cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.html)\n- [MITRE CWE-639 : Authorization Bypass Through User-Controlled Key](https://cwe.mitre.org/data/definitions/639.html)\n- [OWASP Top 10 2025 : A01 Broken Access Control](https://top10.owasp.org/2025/A01_2025-Broken_Access_Control)\n- [WordPress Developer Resources : current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)",
    "definition": "An IDOR (insecure direct object reference) vulnerability lets someone access another user's data simply by changing an identifier in a request, such as an order number in the URL, because the application doesn't check that the requested object actually belongs to the logged-in user.",
    "group": "Web security",
    "aka": [
        "Insecure Direct Object Reference",
        "BOLA",
        "Broken Object Level Authorization",
        "CWE-639"
    ],
    "related": [
        {
            "title": "Privilege escalation",
            "url": "https://www.wp-feint.com/glossary/privilege-escalation/",
            "markdown": "https://www.wp-feint.com/glossary/privilege-escalation/index.md"
        },
        {
            "title": "Nonce",
            "url": "https://www.wp-feint.com/glossary/nonce/",
            "markdown": "https://www.wp-feint.com/glossary/nonce/index.md"
        },
        {
            "title": "CSRF (cross-site request forgery)",
            "url": "https://www.wp-feint.com/glossary/csrf/",
            "markdown": "https://www.wp-feint.com/glossary/csrf/index.md"
        },
        {
            "title": "SQL injection",
            "url": "https://www.wp-feint.com/glossary/sql-injection/",
            "markdown": "https://www.wp-feint.com/glossary/sql-injection/index.md"
        }
    ],
    "sources": [
        {
            "title": "OWASP Cheat Sheet Series : Insecure Direct Object Reference Prevention",
            "url": "https://cheatsheetseries.owasp.org/cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.html"
        },
        {
            "title": "MITRE CWE-639 : Authorization Bypass Through User-Controlled Key",
            "url": "https://cwe.mitre.org/data/definitions/639.html"
        },
        {
            "title": "OWASP Top 10 2025 : A01 Broken Access Control",
            "url": "https://top10.owasp.org/2025/A01_2025-Broken_Access_Control"
        },
        {
            "title": "WordPress Developer Resources : current_user_can()",
            "url": "https://developer.wordpress.org/reference/functions/current_user_can/"
        }
    ],
    "format": "application/json"
}