LMU ☀️ CMSI 662
SECURE SOFTWARE DEVELOPMENT
Practice

Reinforcement Questions

Do you like spaced repetition learning? Have you used Anki or Quizlet? Whether or not spaced repetition works for you, periodically working on flash-card like questions can be a lot of fun, and just may help you retain information. Here are a few problems tied to the course material. Visit them periodically, and feel free to use them in your own spaced repetition learning practice!

Security in General

  1. Security is about the protection of ________________.
    Assets
  2. The term cybersecurity is a synonym for ________________.
    Computer Security
  3. Correctness is related to security in that the correctness is concerned with ensuring a system always ________________ and security is concerned with ensuring a system never ________________.
    (Always) does what it is supposed to
    (Never) does what it is not supposed to
  4. Correctness involves testing ________________cases while security involves testing ________________ cases.
    Use
    Misuse (or Abuse)
  5. What do we call the things we protect our assets from?
    Threats
  6. A security strategy should encompass: (1) prevention, (2) ________________, and (3) ________________.
    Detection
    Reaction
  7. What should be created in the early stages of planning a system so that security is properly address throughout the software life cycle?
    A threat model
  8. “Security is a ________________, not a ________________.”
    Concern
    Feature
  9. Every input to a program is a ________________.
    Potential threat
  10. Name three aspects of a security mindset.
    Simple architectures
    Pristine source code
    Layers of trust
    (Other answers are possible)
  11. What are some high level goals that attackers may have?
    Eavesdropping, spoofing, denial of service, breaking in.
    Were you just going to give the one word answer “profit”?
  12. What kinds of security issues are not under the realm of software security?
    Hardware security
    Physical security (locks)
    Human factors (susceptibility to bribes, threats, and phishing)
  13. What happened on March 25, 1854 to the Öst-Götha Bank in Sweden?
    It was robbed because a blacksmith was able to remove the vault hinges, despite there being high quality locks on the vault
  14. The statement “The system must have a login screen” is a terrible security requirement. What should be said instead?
    Only authenticated users may perform all operations
  15. What is CIA in software security?
    Confidentiality, Integrity, Availability
  16. A successful compromise of confidentiality causes a system to do what?
    Divulge information the attacker should not have
  17. A successful compromise of integrity causes what to happen?
    Important data to be modified or deleted, or malicious content (malware, bots) to be added
  18. A successful compromise of availability causes a system to do what?
    Slow to a crawl, fail to respond to all requests, or crash
  19. What is the difference between authentication and authorization?
    Authentication is ensuring someone is who they say they are
    Authorization is ensuring someone has the permission to do something
  20. What is non-repudiation?
    The impossibility of someone denying that they performed an action
  21. What kind of security features can the hardware provide?
    It can allow certain machine instructions to take place only in kernel mode (not user mode) so regular users can not execute harmful commands.
    It can set read/write/execute permissions on memory blocks, so for example attackers can not inject code into memory and then run it.
  22. What kind of security features can the operating system provide?
    It can protect certain resources (files, processes, memory blocks, devices) so they can only be accessed by certain users
  23. What kind of security features can the network services provide?
    Firewalls, anti-virus, packet filtering, encryption at different layers
  24. What are some human factors in security?
    Malicious insiders, susceptibility to bribes, susceptibility to trickery
  25. What is the difference between a threat and an exploit?
    A threat is something that could happen; an exploit is the actual execution of an attack that compromises confidentiality, integrity, or availability. You might also see the term “exploit” for the code or data itself that carries out the attack, though that is more properly referred to as the “payload”.
  26. How do people usually distinguish the terms bug and flaw?
    A bug is a programming mistake that is generally easy to fix; a flaw is a problem in the design
  27. What is a risk?
    A measure of how bad things could be

Software Security

  1. What are the phases in the software development lifecycle (SDLC)?
    Ideation • Planning • Requirements Analysis and Definition • Architecture and Design • Implementation • Static Analysis and Code Reviews • Testing • Documentation • Integration • Deployment • Maintenance • Evaluation • Retirement • Disposal.
  2. What percentage of reported security incidents result from exploits against defects in the design or code of software?
    90%.
  3. What does it mean to “build security in”?
    It means to design and implement the core domain objects and core business logic to prevent exploits, rather than leaving security concerns to separate libraries with ad-hoc solutions.
  4. “Secure software is better than ________________ software.”
    Security.
  5. Why might you not even need specific security solutions like, say, an XSS Sanitizer?
    If you define your domain objects to be restricted to certain character patterns, XSS attacks can be completely avoided.
  6. What might happen if you don’t build security in, and you give the system to the security experts and pen testers after you finish development?
    The pentesters will find a ton of problems and tell you not to release the project without a massive overhaul.
  7. What might happen if you don’t build security in, and you end up just deploying the system as-is?
    You will get hacked and destroyed.
  8. Secure software development is not really about ethical hacking and penetration testing, but rather about ________________.
    Disciplined software design and development.
  9. What are some coding constructs that increase security?
    Immutability, encapsulation, error isolation, validation.
  10. What are techniques for making sure improving your confidence that your code is secure?
    Manual code reviews and Linters.
  11. What kind of problems do people make when defining security requirements?
    They sometimes mistake a technique or use case for a bigger concern, e.g., saying a login page is a requirement, when the actual requirement is not to divulge information to the wrong user).
  12. Give an example of an exploit stemming from an improperly defined security requirement.
    A requirement that says “users must log in to access a page with links to their photos” says nothing about authenticating the actual service that fetches the photos, so an attacker might easily guess the URLs of anyone’s photos.
  13. What is the meaning of “defense in depth”?
    Having a series of defenses so that if an attack isn't caught by one, it will probably be caught by the next one on the chain, and so on.
  14. What some examples of layered protections that would appear in depth defense?
    Firewalls, anti-virus software, crypto, authentication mechanisms, authorization rules, signatures, correctness proofs.
  15. What is an example of the need to apply defenses broadly, as well as in depth?
    An available attack can exploit flaws stemming from, say, insufficient network bandwidth, filling up hard drives, excessive memory paging or cache invalidations, hash collisions, deadlocks livelocks, bad database queries that don’t use indexes, or slow algorithms.
  16. What are the fancy terms for (1) trusted code in your security zone whose input you can trust, and (2) code from untrusted zones?
    (1) Code-on-the-inside, (2) Code-on-the-edge.
  17. What is the concept of designing for least privilege?
    Having the default situation being that any user or process is able to do the minimum possible to carry out its task, and no more.
  18. What do we define to help maintain integrity?
    Preconditions, postconditions, and invariants.
  19. Why do we have to fail fast?
    An unhandled failure can propagate an inconsistency in state leading to horrifying situations down the line.
  20. Auditing is important for security, especially for forensics and intrusion detection, but we have to be careful when logging. What are the two main concerns?
    Never log secrets, and keep the logs themselves secure.
  21. Why should you not rely on secrets?
    They can be accidentally or maliciously leaked, or divulged by a person who is under threat.
  22. Why should code be kept simple?
    The more complex your code, the greater the attack surface, and the greater chance for the introduction of bugs and flaws.
  23. Why should you be somewhat coy when reporting errors to users?
    The user may be an attacker looking for opportunities so being too-specific about error messages (e.g., distinguishing not found and found-but-you-don’t-have-access, or distinguishing bad-password from unknown-username-OR-password) may leak useful information to an attacker.
  24. What is the difference between security principles and tactics?
    Principles are high level, like “defend in depth, ”fail fast,” “don’t rely on secrets”, and “prevent leaks”. Tactics are specific programming practices like “don’t double-free pointers” or “avoid global variables.”
  25. What are some organizations that publish guidelines and standards for secure software development?
    CERT, OWASP.

Known Vulnerabilities

  1. What are examples of types of exploits?
    Injection, MitM, DOS, Malware, Phishing, Theft, Enumeration.
  2. Why should developers learn the various known vulnerabilities?
    One needs to think like an attacker to know how best to defend.
  3. What is an injection attack?
    Getting code that is authored by the attacker to run on the victim’s machine (without the permission of the victim).
  4. What is the CWE and about how many entries does it have?
    Common Weakness Enumeration, a listing of around 1000 types of weakness.
  5. What is the CVE and about how many entries does it have?
    Common Vulnerabilities and Exposures, a listing of over 100,000 specific vulnerabilities in actual systems.
  6. What does OWASP stand for?
    Open Web Application Security Project.
  7. The famous “OWASP Top Ten” lists the top 10 what?
    Security risks to web applications.
  8. Even though the famous OWASP Top 10 enumerates the top risks faced by web applications, OWASP also publishes a document for the Top 10 Proactive Controls. What are some of these proactive controls?
    Define security requirements • leverage frameworks and libraries • secure your databases • encode/escape data • validate • implement digital identity • enforce access • protect data • log and monitor • handle all errors and exceptions.
  9. Should you read each of the OWASP Cheat Sheets?
    Yes.
  10. What are the three best known security weaknesses on the web?
    XSS, SQL Injection, and CSRF.
  11. How do you defend against stack buffer overflow attacks in your program?
    Never use vulnerable functions like strcpy and strcat.
    Do bounds checking.
    Don’t put user-supplied data into buffers.
    Stop using C and C++.
  12. How can the hardware, operating system, compiler, or runtime system help to avoid buffer overflow attacks?
    Non-executable stack segments, stack canaries, ASLR, CFI.
  13. How do you defend against SQL Injection?
    Use a query library, or prepared statements with bound parameters, NEVER compose raw SQL with string concatenation.
  14. How do you defend against XSS?
    Input validation, performed server-side.
  15. How do you defend against CSRF?
    CSRF Tokens, either kept on the server or through a “double submit cookie”.
  16. How do you defend against replays?
    Nonces (number-used-only-once).
  17. How do you defend against brute-force password attacks?
    Require all passwords to be very long
    Use a slow hash function
    Rate limit the authenciation endpoint
    Enforce rotation
  18. How do you defend against birthday password attacks?
    Ensure your hashing algorithm is very strong and all hashes are salted.
  19. How do you defend against enumeration attacks?
    Avoid sequential ids.

Security in Design

  1. In the early phases on the SDLC we must define not only use cases but also ________________
    Abuse cases.
  2. What things should you document in a Threat Model?
    Your assets • Possible threats • Likely attackers • Vulnerable/weak parts of the system • Prioritized strategies for defense, detection, mitigation, and recovery.

Secure Coding

  1. What are three ways to avoid data corruption via shared references?
    Immutable objects, defensive copying, or prohibiting copying
  2. Why is immutability a main pillar of secure software development?
    Immutable objects free us from worrying about data corruption via shared references, or forgetting to revalidate on update.
  3. How can favoring immutability allow for more efficient software?
    Immutable objects can be shared, so they don’t incur the overhead of being copied. They don’t have to be locked to access them, so concurrent programming is faster and safer too.
  4. What is a persistent data structure?
    A data structure that always preserves its “history”, used when we want immutability of structures that we want to give the appearance of changing.
  5. Validations should be done in order from cheapest to most expensive. List as many as you can
    1. Origin, 2. Authentication, 3. Authorization, 4. State, 5. Size, 6. Lexical, 7. Syntactic, 8. Semantic.
  6. One secure coding rule is “The only good global variable is an immutable one.” Is this okay then, in Java?
    public static final int[] primes = new int[]{2, 3, 5, 7, 11, 13};
    No, you can update the elements of the array.
  7. How is complexity an enemy of security?
    The more complex the software, the more error-prone it is, and the harder it is to reason about its correctness and its security. Every bit of added complexity is a new attack vector.
  8. Why should validations be done in the domain model?
    Improved readability and understandability because behavior is localized and more cohesive.
    Less prone to errors of omission.
    If left outside, the same checks may be required in a number of service functions, which is not DRY.
  9. Why should programmers not write their own sanitization code?
    There are often too many edge cases. Leave sanitization to well-tested libraries.
  10. What is the worst thing you can do with errors in software?
    Ignore them, as this will likely lead to a corrupted state and loss of data integrity, which can just magnify over time to the point where you cannot recreate a proper state.
  11. What is the meaning of “fail fast”?
    Reporting errors and taking action immediately (never continuing normal operation)
  12. What does it mean to “throw” an error?
    The existing control flow is disrupted; control is transferred to a designated place where the error is “caught” and handled.
  13. Instead of throwing an error, we can return an error object from an operation. How can this be done safely?
    As a typesafe discriminated union object, summing the error type with the type of the function’s successful return value.
  14. Why is it not a good idea to indicate errors through mutable arguments?
    The caller might forget to check them.
  15. What condition in programming is often misunderstood by programmers to be an error that actually isn’t?
    An optional value that isn’t present.
  16. What is one of the most common ways to reduce the cyclomatic complexity of software?
    Replacing if-statements with a more declarative dispatch architecture.

Security in Testing

  1. What are (at least) two things you can employ to check compliance with secure coding rules?
    (1) Static analysis tools and (2) human code reviews.
  2. What is the difference between white box and black box testing?
    In white box testing you have access to the source code; in black box you do not.
  3. What is fuzz testing?
    Testing with a large suite of machine-generated tests. The tests include a mixture of specially-crafted tests to exercise edge cases and well as lots of random tests too.
  4. What is penetration testing?
    An authorized set of attacks by an ally to help assess weaknesses and risks in a system so they can be patched by the system’s owner.

Security in Operations

  1. What is SecOps?
    The collection of all people, practices, intelligence, and technology that goes into securing an enterprise’s assets. It handles threat modeling, risk assessment and management, bug (vulnerability) reports and issue tracking, responses and fixes, configuration, rollout, deployment, maintenance, evolution, etc., with security in mind the whole time.

Secure C

  1. What is perhaps the most unsafe aspect of C?
    It lacks memory safety.
  2. What is the difference between rules and recommendations in the CERT-C Coding Standard?
    Rules are requirements that if violated will almost surely result in an exploitable vulnerability. Recommendations basically improve software quality, but violations are not necessarily defects.

Secure C++

Secure Java

Secure JavaScript

Crypto

Authentication and Authorization

  1. Which of authentication and authorization is concerned with users proving they are who they say they are?
    Authentication.
  2. Which of authentication and authorization is concerned with managing permissions?
    Authorization.
  3. Access control lists are examples of ________________?
    Authorization.
  4. What does IAM stand for?
    Identity and Access Management.
  5. What are the three major factors that can be used to authenticate a user?
    Something you KNOW
    Something you HAVE
    Something you ARE.
  6. What attack is sufficient against short passwords?
    Brute-Force Attack
  7. What attack is used to guess passwords that takes into account the fact that some passwords are more common than others?
    Dictionary Attack
  8. Should user passwords ever be stored encrypted? Why or why not?
    NO! Never store them encrypted. Encrypting something implies that you can decrypt it and you never need to know a user’s password. Hash it instead.
  9. Why must password hashing algorithms be slow?
    To drastically reduce the number of password cracking attempts per second
  10. Why must you salt password hashes?
    If you don’t salt, everyone with the same password gets the same hash, and attackers can make note of the frequency of hashes to assist in cracking, and compromise more users if a commonly-appearing hash is inverted.
  11. What is a common attack used against unsalted hashes that is more efficient than the brute-force or dictionary attack?
    Rainbow Attack
  12. Why do many systems use a shadow password file?
    The original /etc/passwrd file on Unix systems contained the password hash and was world-readable; these days it does not, and the actual hash is now kept in a (shadow) location readable only by a superuser.
  13. Do most security experts recommend password managers these days?
    Yes. The risk of losing the single password to the vault or password manager, while indeed catastrophic, can be made extremely low, while the odds of losing one or more of your 50 varying credentials that are kept who knows where will always be much higher.

Network Security

Web Security

Privacy

  1. Security is protection from ________________; privacy is protection from ________________.
    Harm. Being identified or observed.
  2. What is the field of differential privacy concerned with?
    Ensuring the anonymity of individuals or their attributes when their information is part of a disseminated dataset.
  3. What does RTBF stand for?
    Right To Be Forgotten
  4. What does GDPR stand for and which organization is behind it?
    General Data Protection Regulation. European Union.

Find the Vulnerability

  1. ...
  2. ...
  3. ...
  4. ...

Programming Secure Implementations

  1. ...
  2. ...
  3. ...
  4. ...