Secure Software Development MCQs for NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Secure software development means building security into every stage of writing software: secure coding habits, strict input validation, and a secure software development life cycle (SDLC) with threat modelling and security testing. It is the ninth topic in the Cyber Security area, which carries 5% of the NSCT according to HEC's Areas of Competencies. That area had 47.2% accuracy in 2026, per the HEC NSCT report and APP.

This page follows the software security chapters of Stallings and Brown, Computer Security: Principles and Practice, plus the OWASP and Microsoft SDL guidance that exam questions draw on. Specific web attacks such as XSS and CSRF are covered in Web Application Security.

Secure coding

Secure coding means writing code that stays safe when it gets hostile input or hits an error. The core habits:

These follow Saltzer and Schroeder's design principles, such as fail-safe defaults (deny unless explicitly allowed), least privilege and complete mediation (check every access).

Compiler and OS mitigations reduce the damage but do not fix the bug: stack canaries detect overwrites of the return address, ASLR randomises addresses, and NX/DEP stops code running from the stack.

Exam angle: if the error path returns "allow", the code fails open, which is the bug to spot.

Input validation

Input validation checks that data has the expected type, length, format and range before the program uses it.

Approach How it works Verdict
Allow-list Accept only known-good values or patterns Preferred
Deny-list Reject known-bad strings such as <script> Easy to bypass
Client-side only JavaScript checks in the browser Convenience only; attackers skip it
Server-side Checks on the server before use Required

Two rules that catch many students:

  1. Canonicalise first. %2e%2e%2f decodes to ../. A filter that checks before decoding misses it, so decode to a single standard form, then validate.
  2. Validate the whole string. In Python, re.match(r"\d+", "7; rm") succeeds because it only anchors at the start. re.fullmatch checks the whole input.

Validation is not the only defence. Put data into queries with parameterised statements, so input can never change the SQL logic. When you write it into HTML, use context-aware output encoding (< becomes &lt;).

Exam angle: deny-list answers are almost always the distractor.

Secure SDLC

A secure SDLC adds security activities to each phase instead of testing only at the end. Microsoft's classic Security Development Lifecycle (SDL) has seven phases: Training, Requirements, Design, Implementation, Verification, Release and Response.

Threat modelling in design maps data flows and trust boundaries and asks what can go wrong. Microsoft's STRIDE gives the checklist:

Threat Property violated
Spoofing Authentication
Tampering Integrity
Repudiation Non-repudiation
Information disclosure Confidentiality
Denial of service Availability
Elevation of privilege Authorisation

Security testing tools differ in what they see:

Tool Needs running app? Finds
SAST (static) No Unsafe code patterns, hard-coded secrets
DAST (dynamic) Yes Runtime and configuration flaws
SCA (composition analysis) No Known CVEs in third-party libraries
Fuzzing Yes Crashes from malformed input

Shift left (the DevSecOps idea) means doing these checks as early as possible, because a design flaw found in design costs far less to fix than one found after release.

Exam angle: "flaw in an open-source library" points to SCA, not SAST.

Common traps

Worked examples

1. Understanding. In STRIDE, an attacker denies having placed an order because the system keeps no log of who did what. Which category is this? Answer: Repudiation. The threat is to non-repudiation. Secure audit logs, and digital signatures where needed, are the mitigations.

2. Application. A Python filter removes the string .. once from a file name using name.replace("..", "", 1). What is left of the input ....//secret.txt? Answer: ..//secret.txt. Only the first .. is removed, leaving ..//secret.txt, which still climbs a directory. Validate the canonical path against the base folder instead of stripping strings.

3. Analysis. Code review finds if (check_license() != ERROR) grant_access();, where check_license() returns OK, INVALID or ERROR. Why is this unsafe? Answer: an INVALID licence still gets access. The condition grants access for anything except ERROR, which breaks fail-safe defaults. It should grant access only when the result equals OK.

Practise

The quiz below has 98 questions on this topic, filterable by tier and difficulty.

Practise: 98 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. For input validation, which approach do secure coding guides such as OWASP recommend as the primary method?

    1. Allow-listing: accept only input that matches a defined set of valid values or patterns
    2. Deny-listing: block a list of known bad characters
    3. Accepting all input and fixing problems later
    4. Validating only in the browser with JavaScript
    Show answer

    Answer: A. Allow-listing: accept only input that matches a defined set of valid values or patterns

    An allow-list (whitelist) defines exactly what is valid and rejects everything else, so unknown attack strings fail by default. Deny-lists always miss some encodings or variations. Browser checks are a convenience only, because attackers can bypass the browser.

  2. Why do parameterised queries (prepared statements) prevent SQL injection?

    1. They encrypt the database
    2. They remove all spaces from user input
    3. They run the query with administrator rights
    4. The SQL structure is fixed first and user input is sent separately as data, so it can never change the query's logic
    Show answer

    Answer: D. The SQL structure is fixed first and user input is sent separately as data, so it can never change the query's logic

    With a prepared statement the database parses the query with placeholders before any user data arrives. The data is then bound to the placeholders, so characters such as quotes are treated as data, not as SQL code.

  3. What does static application security testing (SAST) do?

    1. Attacks the running application from outside, like a user
    2. Analyses source code or binaries for vulnerabilities without running the program
    3. Monitors production traffic for attacks
    4. Checks only the server's network ports
    Show answer

    Answer: B. Analyses source code or binaries for vulnerabilities without running the program

    SAST tools read code to find patterns such as SQL built by string concatenation, unsafe functions or hard-coded secrets. Because they need no running system, they can run early, for example on every commit.

  4. Dynamic application security testing (DAST) is best described as:

    1. Testing the running application from the outside by sending crafted requests and observing responses
    2. Reading the source code line by line
    3. Reviewing the design documents
    4. Checking third-party library versions
    Show answer

    Answer: A. Testing the running application from the outside by sending crafted requests and observing responses

    DAST treats the application as a black box: it sends malicious or unexpected inputs to a deployed system and looks for vulnerable behaviour. It finds runtime and configuration problems but cannot point to the exact line of code.

  5. What is the main purpose of threat modelling in secure software development?

    1. To measure how fast the code runs
    2. To count lines of code
    3. To replace testing completely
    4. To identify likely threats and design weaknesses early, usually during design, so mitigations can be planned
    Show answer

    Answer: D. To identify likely threats and design weaknesses early, usually during design, so mitigations can be planned

    Threat modelling looks at the system's components, data flows and trust boundaries and asks what could go wrong. Finding a design flaw at this stage is much cheaper than fixing it after release.

  6. In Microsoft's STRIDE threat model, which threat category violates integrity?

    1. Spoofing
    2. Repudiation
    3. Information disclosure
    4. Tampering
    Show answer

    Answer: D. Tampering

    STRIDE maps each threat to a property: Spoofing to authentication, Tampering to integrity, Repudiation to non-repudiation, Information disclosure to confidentiality, Denial of service to availability, and Elevation of privilege to authorisation.

  7. What is fuzz testing (fuzzing)?

    1. Reviewing code with a colleague
    2. Encrypting test data
    3. Automatically feeding large numbers of malformed or random inputs to a program to find crashes and unexpected behaviour
    4. Writing unit tests for expected inputs only
    Show answer

    Answer: C. Automatically feeding large numbers of malformed or random inputs to a program to find crashes and unexpected behaviour

    Fuzzers generate unexpected inputs at scale and watch for crashes, hangs or memory errors. It is very effective at finding input-handling bugs such as buffer overflows.

  8. Which secure coding practice is the main defence against cross-site scripting (XSS) when user data is placed in an HTML page?

    1. Context-aware output encoding, for example turning < into &lt;
    2. Hashing the user's password
    3. Using HTTPS
    4. Increasing the session timeout
    Show answer

    Answer: A. Context-aware output encoding, for example turning < into &lt;

    XSS happens when user-supplied text is interpreted as HTML or script. Encoding special characters for the output context (HTML body, attribute, JavaScript or URL) makes the browser display them as text instead of running them.

  9. What does 'shift left' mean in secure software development and DevSecOps?

    1. Moving all testing to after release
    2. Moving security activities earlier in the life cycle, such as requirements, design and coding
    3. Letting the operations team handle all security
    4. Removing security reviews to speed up delivery
    Show answer

    Answer: B. Moving security activities earlier in the life cycle, such as requirements, design and coding

    On a timeline drawn left to right, earlier phases are on the left. Shifting left means doing threat modelling, secure coding checks and automated testing early, where defects are cheaper to fix.

  10. A buffer overflow occurs when:

    1. A server receives too many network requests
    2. A database table runs out of rows
    3. A user types the wrong password too often
    4. A program writes more data into a buffer than it can hold, overwriting adjacent memory
    Show answer

    Answer: D. A program writes more data into a buffer than it can hold, overwriting adjacent memory

    Stallings describes a buffer overflow as input written past the end of a fixed-size buffer. The extra bytes overwrite nearby data or control information such as a return address, which can crash the program or let an attacker take control. It is common in C and C++, which have no automatic bounds checking.

FAQs

What is the difference between input validation and output encoding?

Input validation checks that incoming data has the right type, format and range, and rejects anything else. Output encoding changes special characters when data is written into a particular context, such as HTML, so the browser treats it as text. You need both: validation narrows what enters, and encoding makes what leaves safe for its context.

What is the difference between SAST and DAST?

SAST analyses source code or binaries without running them, so it can run on every commit and points to the exact line. DAST attacks a running application from the outside and finds runtime and configuration problems, but cannot show the faulty line. Most teams use both, plus SCA for third-party libraries.

What is a secure SDLC?

A secure SDLC adds security work to every phase of development: security requirements, threat modelling in design, secure coding and code review in implementation, security testing in verification, and an incident response plan after release. Microsoft's SDL is the best-known example. The goal is to find flaws early, when they are cheapest to fix.

Partly. HEC lists Secure Software Development under Cyber Security, while Software Engineering is a separate 10% area. The ideas overlap with Software Security Engineering, so studying both together saves time.

Next step

Continue with Wireless & Mobile Security MCQs. For the attacks these practices prevent, see OWASP Top 10. Browse all topics on the Cyber Security hub, then take an NSCT mock test.