Skip to content

Security: Unauthenticated access to system tables (Access/Function/Script/Request) exposes permission configs and script codeย #857

@icysun

Description

@icysun

Summary

APIJSON's default @MethodAccess configuration allows unauthenticated (UNKNOWN role) GET/HEAD requests to system tables including Access, Function, Script, and Request. This exposes the complete permission configuration, remote function definitions, and potentially business logic script code to any network-reachable attacker.

Impact

CVSS 5.3 (Medium) โ€” Information disclosure of permission configs, function signatures, and script code without authentication.

Details

System tables with default @MethodAccess

// APIJSONORM/src/main/java/apijson/orm/model/Access.java:13
@MethodAccess(POST = {}, PUT = {}, DELETE = {})
public class Access {}

// Similar for Function.java, Script.java, Request.java

@MethodAccess(POST = {}, PUT = {}, DELETE = {}) means GET and HEAD requests are not restricted โ€” they default to allowing all roles including UNKNOWN (unauthenticated).

What gets exposed:

Table Data Exposed
Access Complete permission config (which tables/operations for which roles)
Function Remote function method signatures and configurations
Script Business logic script code (if Script feature is used)
Request Request validation logic including JavaScript/Groovy scripts

Attack:

GET /get/Access      โ†’ Permission configuration for all tables
GET /get/Function    โ†’ Remote function definitions
GET /get/Script      โ†’ Script code
GET /get/Request     โ†’ Request validation structures (may contain JS/Groovy code)

No authentication required.

Additional Findings

1. SQL Injection when prepared=false

When prepared = false (set by AbstractParser.java:1107 in certain code paths), multiple user inputs bypass SQL validation:

  • @having โ€” expressions without () directly concatenated
  • @order โ€” column names not validated
  • key{} โ€” range conditions not checked against PATTERN_RANGE
  • @column โ€” function parameters not checked for -- or _ prefix

While prepared=true is the default, the security model is fragile โ€” a single setPrepared(false) call exposes all injection surfaces.

2. Remote Function/Script Execution Default Enabled

public static boolean ENABLE_REMOTE_FUNCTION = true;
public static boolean ENABLE_SCRIPT_FUNCTION = true;

Combined with the information disclosure above, an attacker can enumerate all configured functions and scripts, then look for exploitable configurations.

Suggested Fix

  1. Restrict system table access to authenticated users:
@MethodAccess(GET = {}, HEAD = {}, POST = {}, PUT = {}, DELETE = {})
public class Access {}
  1. Add deny-by-default for system tables in the framework's request handler
  2. Consider making security independent of the prepared flag โ€” SQL validation should always apply

References

  • CWE-200: Exposure of Sensitive Information
  • CWE-862: Missing Authorization

Discoverer

IcySun (icysun@qq.com)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions