Courseiva
mediumMultiple SelectObjective-mapped

CAS-004 Practice Question: Which three options are best practices for…

Which three options are best practices for writing secure scripts? (Choose three.)

⚠ Common exam trap

The CASP+ exam tests the misconception that logging all errors is always a best practice, but in secure scripting, excessive logging can leak sensitive data, making it a security risk rather than a safeguard.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Use parameterized inputs to prevent injection attacks.

Parameterized inputs (also known as prepared statements or parameterized queries) separate SQL or shell command logic from user-supplied data, ensuring that input is treated strictly as data, not executable code. This prevents injection attacks such as SQL injection or command injection, which occur when untrusted input is concatenated directly into a command string. In scripting languages like Python, using `cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))` instead of string formatting eliminates the risk of an attacker breaking out of the intended syntax.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Log all errors and warnings for debugging.

    Why it's wrong here

    Logging is important but not a direct security best practice.

  • Use parameterized inputs to prevent injection attacks.

    Why this is correct

    Parameterization separates code from data.

  • Validate all external input before processing.

    Why this is correct

    Validation prevents malicious input from causing harm.

  • Hardcode sensitive credentials in the script.

    Why it's wrong here

    Hardcoding exposes secrets if the script is compromised.

  • Run scripts with the least privilege necessary.

    Why this is correct

    Least privilege reduces the impact of a compromise.

About these practice questions

This CAS-005 question is part of Courseiva's 968-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CAS-005 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CAS-005 exam.