Defensive Coding Practices – Concepts and Techniques Flashcards

1
Q

Input validation is the verification process that ensures the data that is supplied for processing is …

A

of the correct data type and format; falls within the expected and allowed range of values; is not interpreted as code as is the case with injection attacks; does not masquerade in alternate forms that bypass security controls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Canonicalization (or C14N) is the process of …

A

converting data that has more than one possible representation to conform to a standard canonical form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sanitization is the process of …

A

converting something that is considered dangerous into its innocuous form. Both inputs and outputs can be sanitized.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Input sanitization is the process of …

A

transforming the data that is supplied by the user before it is processed. Methods are Stripping, Substitution, Literalization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two of the most basic and effective protection mechanisms that can be used to mitigate a lot
of software attacks?

A

Input validation and output error handling importance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Clipping level is the tolerance of …

A

user errors which are inevitable, permitting a pre-determined number of user errors before recording it as a security violation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Threat modeling should identify API as …

A

potential entry points; banned and deprecated APIs that are susceptible to security breaches should be avoided and replaced with secure counterparts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The Locality of Reference, also known as the principle of the locality, is the principle that subsequent data locations that are referenced when a program is run are often …

A

predictable and in proximity to previous locations based on time or space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dangling pointers are those pointers that … These occur when the object that the pointer was originally referencing was …

A

do not point to a valid object of the appropriate type in memory; deleted or de-allocated without the pointer value being modified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The wild pointers are used prior to …

A

being initialized but they have been known to result in similar erratic, unpredictable, and dangerous results as dangling pointers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

From Wild pointers and Dangling pointers, attackers can take advantage and initiate …

A

overflow attacks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A memory leak occurs when …

A

the memory buffer object that is allocated to hold some variable becomes unreachable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The main goal of garbage collection is to …

A

reduce memory leaks i.e., reclaiming unreachable memory objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ARC

A

Automatic Reference Counting - a way of garbage collection wherein each object in memory keeps a count of the number of pointer references to it. Each time a reference to the object is made, the reference count is incremented. Whenever, a reference to the object is destroyed, then the reference count is decremented.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Fast death attack frequently subjecting the garbage collector to go into …

A

overdrive in its function resulting in the system coming to a halt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Slow death attack is when the attacker requests …

A

additional memory that the garbage collector has to invoke, but they do so at a rate that is not quite as severe to throw an out-of-memory exception. In slow death, the CPU cycles are stolen, when memory is being occupied.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Type safety is an important consideration when choosing between a managed and unmanaged programming language. Type-safe code cannot access memory at …

A

arbitrary locations out of the range of memory address space that belongs to the object’s publicly exposed fields, it prevents Buffer overflow vulnerabilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

CAS

A

Code access security (CAS) prevents code from untrustworthy sources or unknown origins from having run time permissions to perform privileged operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

In addition to type safety, CAS concepts include the following …

A

Syntax Security (Declarative and Imperative); Security Actions; Secure Class Libraries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Exceptions are software issues that are not

A

handled explicitly when the software behaves in an unintended or unreliable manner.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

In Exception Management, all exceptions must be …

A

explicitly handled in order to avoid disclosing the entire exception stack. This can result in information disclosure potentially revealing the software’s internal architectural details and in some cases even the data value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Safe Security Exception Handler (/SAFESEH) flag in systems that support it is an important exception management feature that can be leveraged during the …

A

compilation and linking process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

In a Session hijacking attacks, an attacker …

A

impersonates the identity of a valid user and interjects themselves into the middle of an existing session, routing information from the user to the system and from the system to the user through them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

When a session is hijacked, it can lead to …

A

information disclosure (confidentiality threat), alteration (integrity threat), or a denial of service (availability threat).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Session management is a security concept that aims at …

A

mitigating session hijacking or MITM attacks; it requires that the session is unique by the issuance of unique session tokens and it also requires that user activity is tracked so that someone who is attempting to hijack a valid session is prevented from doing so.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Secure startup prevents and mitigates …

A

side-channel attacks such as the Cold Boot attack.

27
Q

Insecure cryptographic vulnerabilities are primarily comprised of the …

A

use of a weak or custom-developed unvalidated cryptographic algorithm for encryption and decryption needs; The use of older cryptographic APIs; Insecure and improper key management; Inadequate and improper storage of the data (data at rest) that needs to be cryptographically secure; insufficient access control that gives users direct access to unencrypted data; violation of least privilege giving users elevated privileges.

28
Q

Prevention and mitigation techniques to address insecure cryptography issues are …

A

Data at rest protection controls; Appropriate algorithm usage; Cryptographic Agility; Secure key management; Adequate access control and auditing.

29
Q

Appropriate algorithm usage means the algorithm used for encryption and decryption purposes is …

A

not custom developed; a standard (such as the AES) and not a historically proven weak one (such as DES); older cryptography APIs (CryptoAPI) are not used and replaced with the Cryptography API; The design of the software takes into account the ability to quickly swap cryptographic algorithms as needed.

30
Q

CNG

A

Cryptography API Next Generation (CNG) is intended to be used by developers to provide secure data creation and exchange over non-secure environments such as the Internet and is extremely extensible because of its cryptography agnostic nature.

31
Q

Cryptographic agility means the application is architected to …

A

reference the cryptographic algorithm or hashing function outside the application code itself, so that it can be easily swapped, when required.

32
Q

One of the predominant flaws of cryptographic protection implementation in code is the use of …

A

unvalidated and custom-developed or weak cryptographic algorithms for encryption and decryption or noncollision-free hashing functions for hashing purposes.

33
Q

Types of Symmetric Banned Algorithm

A

DES, DESX, RC2, SKIPJACK, SEAL, CYLINK_MEK, RC4 (<128bit).

34
Q

Types of Asymmetric Banned Algorithm

A

RSA (<2048bit), Diffie-Hellman(<2048bit)

35
Q

Types of Hash (including HMAC usage) Banned Algorithm

A

SHA-0 (SHA), SHA-1, MD2, MD4, MD5

36
Q

Symmetric Acceptable or Recommended Algorithm

A

3DES (2 or 3), RC4 (>=128bit), AES

37
Q

Asymmetric Acceptable or Recommended Algorithm

A

RSA(>=2048bit),Diffie-Hellman(>=2048bit), ECC(>=256bit)

38
Q

Hash (including HMAC usage)

A

SHA-2 (includes: SHA-256, SHA-384, SHA-512)

39
Q

CNG is the replacement to the CryptoAPI; CNG gives developers the ability to …

A

enable users to create and exchange documents and data in a secure manner over non-secure environments such as the Internet.

40
Q

The main features of CNG include …

A

A new cryptographic configuration system that supports better cryptographic agility; Abstraction for key storage and separation of the storage from the algorithm operations; Process isolation for operations with long-term keys; Replaceable random number generators; Better export signing support; Thread-safety throughout the stack; Kernel-mode cryptographic API.

41
Q

Cryptographically agile code however poses some challenges such as:

A

Different algorithm can yield an ouput with different size; Persisted (stored) data that is encrypted with an replaced algorithm or even a password stored using a hash algorithm.

42
Q

Secure key management means that the generation of the keys uses a …

A

random or pseudo-random number generator (RNG or PRNG) and is random or pseudo-random in nature.

43
Q

Secure key management means that the exchange of keys is done securely using …

A

out-of-band mechanisms or approved key infrastructure that is secure as well.

44
Q

Secure key management means that the storage of keys is protected, preferably in a system that …

A

is not the same as that of the data, whether it is the transactional system or the backup system.

45
Q

Secure key management means that the rotation of the key where one key is replaced by another follows the appropriate process of …

A

first decrypting data with the old key that will be replaced and then encrypting data with the new key that is replacing the old key.

46
Q

Secure key management means that the archival and escrowing of the key is protected with appropriate …

A

access control mechanisms and preferably not archived in the same system as the one that contains the encrypted data archives.

47
Q

Secure key management means that the destruction of keys ensures that …

A

once the key is destroyed, it will never again be used.

48
Q

Adequate access control and auditing mean that for both internal and external users, access to the cryptography keys and data is …

A

granted explicitly; controlled and monitored using auditing and periodic reviews; not inadvertently thwarted by weaknesses such as insecure permissions configurations; contextually appropriate and protected, irrespective of whether the encryption is one-way or two-way.

49
Q

Some of the prevalent protection measures against race conditions or TOC/ TOU attacks are …

A

Avoid race windows; Atomic operations; Mutual Exclusion (Mutex).

50
Q

A race window is defined as …

A

the window of opportunity when two concurrent threads race against one another trying to alter the same object.

51
Q

Atomic operations mean that …

A

the entire process is completed using a single flow of control and that concurrent threads or control flow against the same object is disallowed.

52
Q

Mutual Exclusions or Mutex can be accomplished by …

A

resource locking, wherein the object that is accessed is locked and does not allow any alteration until the first process or threat releases it.

53
Q

PCI DSS prevents the storage of …

A

the primary account number (PAN) of the cardholder in the retailer’s point-of-sale (POS) systems on in a data store after it has been used in a transaction.

54
Q

Tokenization is the process of …

A

replacing sensitive data with unique identification symbols that still retain the needed information about the data, without compromising its security.

55
Q

Tokenization is usually evident in protecting cardholder information, its application can be extended to protect …

A

the confidentiality of any sensitive data, including banking transactions, medical records, criminal records, stock trading, and voter registrations.

56
Q

Sandboxing is the security mechanism that …

A

prevents software from running on a system accessing the host operating system; sandboxing is an example of the principle of least privilege.

57
Q

Examples of OS-level sandboxing are …

A

Unix chroot jail, AppArmor, and SELinux.

58
Q

Code signing (covered under Anti-Tampering techniques) ensures …

A

the integrity and authenticity of the software code, besides giving the code the runtime permissions needed to access the host’s sandboxed operating system.

59
Q

Anti-tampering techniques assure …

A

integrity assurance and protection against unauthorized and malicious alterations of the software code and/or the data.

60
Q

Some of the well-known anti-tampering techniques include …

A

obfuscation, protection against reverse engineering, and code signing.

61
Q

Obfuscation is the process of …

A

making the code obscure and confusing using a special program called the obfuscator so that even if the source code is leaked to or stolen by an attacker, the source code is not easily readable and decipherable.

62
Q

Reverse engineering can be used for security research and to determine vulnerabilities in published software.
Anti-Reversing Techniques is the process to prevent an attacker for …

A

gleaning information about the design and implementation details of the software from the object code.

63
Q

Code signing is the process of …

A

digitally signing the code (executables, scripts,

etc.) with the digital signature of the code author.

64
Q

Code signing assures …

A

the authenticity of published code (especially mobile code) besides providing integrity and anti-tampering protection.