cybersecurity · intermediate · ~15 min · safe pentest lab

World-writable file?

Flag world-writable permissions in an audit.

Challenge

Flag a world-writable file — a top finding in a permission audit, since any local user can tamper with it.

Task

Implement int audit_world_writable(int mode) that returns 1 if the other-write bit (octal 0002) is set, else 0.

Input

  • mode: a Unix permission mode (octal). The grader passes fixed values.

Output

Returns int: 1 if the other-write bit is set, else 0.

Example

audit_world_writable(0777)   ->   1
audit_world_writable(0755)   ->   0

Edge cases

  • Only the other-write bit matters; owner/group write bits are ignored.

Rules

  • AND the mode with octal 0002.

Input format

A Unix permission mode (octal int).

Output format

An int: 1 if the other-write bit (0002) is set, else 0.

Constraints

Test mode & 0002.

Starter code

int audit_world_writable(int mode) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.