Securing Servers by Restricting Globally Writable Folders

CAS-005 By islever Editorial Last updated

Given a scenario, analyze requirements to enhance the security of endpoints and servers.

Short answer

C The analyst should implement OS restrictions of globally writable folders to prevent attackers from placing and executing malicious binaries in locations like /tmp.

Question

A SOC analyst is investigating an event in which a penetration tester was able to successfully create and execute a payload. The analyst pulls the following command history from the affected server:
$ uname -a && env
$ vim foo.c
$ gcc foo.c /tmp/lockfile
$ chmod +x /tmp/lockfile
$ ./tmp/lockfile
Which of the following should the analyst implement to improve the security of the server?
  1. Kernel-supported ASLR controls
  2. Application controls with allow lists
  3. OS restrictions of globally writable folders Correct Answer
  4. EDR signatures that terminate specific processes

Key Takeaways

The trap is focusing on runtime controls (EDR/ASLR) instead of the foundational file system security failure that allowed the attacker to write the executable in the first place.

This CAS-005 question demonstrates how to secure a server against payload execution by restricting permissions on globally writable folders like /tmp, preventing unauthorized binary creation.

Common mistake: Choosing EDR signatures (D) because it seems like a modern security tool, but failing to realize that signatures are reactive and do not fix the permissive directory permissions that enabled the attack.

Expert Analysis

The Attack Vector: Compromised /tmp The command history reveals a classic exploitation path: the attacker compiled source code (gcc foo.c) and placed the executable binary directly into /tmp/lockfile. The key vulnerability here is that /tmp is typically a world-writable directory. This allows any user (or compromised process) to create, modify, or execute files in this location, facilitating arbitrary code execution.

Eliminating Distractors Option A (ASLR) mitigates memory corruption exploits but does not prevent an attacker from simply writing and executing a new binary file if they have write permissions to the folder. Option D (EDR signatures) is reactive; while helpful for detection, it does not address the underlying architectural flaw of allowing unauthorized executables in shared directories. Option B (Application allow lists) is a strong control, but it is overly broad and complex to implement compared to fixing the immediate file system permission issue.

Why C is Correct Option C addresses the root cause: the lack of restrictions on globally writable folders. By implementing OS-level restrictions (such as noexec mount options or restricting write permissions to specific users/groups), the server prevents the creation of executable payloads in /tmp. As noted in community feedback, "Restricting or hardening" these folders stops the attacker from placing the payload where it can be executed. This aligns with CIS Benchmarks and NIST guidelines for securing Linux environments.

Conclusion The question tests the ability to identify insecure default configurations. The presence of a compiled payload in /tmp proves that global write access was exploited. Restricting this access is the most direct and effective preventive measure.

Exam Strategy

When analyzing command-line attacks, always look at where artifacts were created. If a payload appears in a shared directory like /tmp or /var/tmp, the primary defense is file system permission hardening (like noexec mounts), not just application-layer filtering. Prioritize eliminating the storage vector before relying on detection tools.

Frequently Asked Questions

Why isn't ASLR the correct answer for this scenario?

ASLR protects against memory corruption by randomizing memory addresses, but it does not prevent an attacker from writing and executing a new binary file if they have write access to the directory.

How do you restrict globally writable folders in Linux?

You can mount them with the 'noexec' option to prevent execution, or change ownership/permissions to ensure only authorized users can write to them, following CIS Benchmarks.

More CAS-005 FAQ →

Community Votes

C
50%
B
50%

50% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 2 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 2

  1. jamestkd 👍 1 Answered C
    The correct answer is C. OS restrictions of globally writable folders. Explanation: The Attack: In the command history, the penetration tester wrote source code (vim foo.c), compiled it using gcc, outputted the compiled binary directly into a globally writable directory (/tmp/lockfile), made it executable (chmod +x), and executed it from there (./tmp/lockfile). The Prevention: Restricting or hardening globally writable folders (such as /tmp, /var/tmp, or /dev/shm) by mounting them with flags like noexec prevents the execution of binaries directly from those temporary or shared locations. This stops attackers from dropping and running unauthorized payloads.
  2. Skri113xX 👍 1 Answered B
    My gut says B. It aligns with best practices.

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All CAS-005 Questions

Access 135 questions with complete answers and detailed explanations.

View Full CAS-005 Practice Test →

← Back to CAS-005 Study Guide