Finals Study Databases

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/245

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

246 Terms

1
New cards

Digital Crime

Crimes done using computers/networks.
Same goals as old crimes, but easier to scale.
ex. Fraud, theft, vandalism happening online.

2
New cards

Digital Version of Old Crimes

Traditional crimes re-done through digital systems.
Helps you recognize the “crime type” even when tech is new.
ex. Spam = junk mail, phishing = fraud, hacking = theft.

3
New cards

Access (What Changed)

Attackers can reach systems remotely.
No physical break-in needed; global reach.
ex. Attacker not in the same building/country.

4
New cards

Cross-Border Law / Jurisdiction

Countries try to enforce laws on content/services across borders.
Rules get messy when data is reachable worldwide.
ex. A service hosted in one country affected by another’s laws.

5
New cards

SQL Injection (SQLi)

Using input to make a dynamic SQL query do something it shouldn’t.
Can expose or change data, or bypass login.
ex. Input changes the logic of a WHERE clause.

6
New cards

Dynamic Query

A query that is built at runtime using user input.
This is where SQLi happens if input is trusted.
ex. Server code “builds” SQL from typed text.

7
New cards

String Concatenation (in Query Building)

Building SQL by sticking strings + user input together.
The classic cause of SQLi.
ex. Query text has the user’s text directly inside it.

8
New cards

User Input (Untrusted Data)

Anything the user sends (forms, URLs, search boxes).
Attackers control it.
ex. Text fields, query parameters, login fields.

9
New cards

Search Box SQLi

Manipulating a search input so the query returns more than intended.
Often leaks entire tables.
ex. A search meant for one product returns everything.

10
New cards

WHERE Clause

The part of SQL that filters which rows you get.
SQLi often targets this logic.
ex. Conditions like Name LIKE …, User=… AND Password=…

11
New cards

LIKE Operator

SQL pattern-matching operator (often used for searching).
Wildcards can be abused to match everything.
ex. WHERE Name LIKE '%text%'

12
New cards

Wildcard (%)

Pattern that matches “anything” in a LIKE search.
Can force results to include all rows.
ex. LIKE '%' matches every string.

13
New cards

OR Operator

Makes a condition true if either side is true.
Attackers use OR to bypass intended filters.
ex. condition1 OR condition2

14
New cards

Always-True Condition

A condition that is true for all rows.
Turns filtering into “return everything.”
ex. 1=1 (or '1'='1') inside a WHERE clause.

15
New cards

AND vs OR Precedence

AND is evaluated before OR (unless parentheses change it).
Injection exploits rely on how SQL groups conditions.
ex. User=… AND Pass=… OR 1=1 may become true due to OR at the end.

16
New cards

Authentication

Proving you are who you claim to be.
SQLi can let attackers authenticate without real credentials.
ex. Login form → server query checks username/password.

17
New cards

Authorization

What you’re allowed to do after you’re authenticated.
SQLi can skip authentication and get unauthorized access.
ex. Seeing admin-only pages/data.

18
New cards

Authentication Query Pattern (COUNT(*))

Login query that returns a count of matching users.
If injection makes count > 0, login passes.
ex. COUNT(*) used instead of returning full user rows.

19
New cards

COUNT(*)
ex. SELECT COUNT(*) …

Returns number of rows matched by the query.
Used in authentication checks; must be tightly controlled.

20
New cards

Authentication Bypass

Getting “logged in” without the correct username/password.
High-impact SQLi outcome.
ex. Login succeeds with nonsense input.

21
New cards

Data Exposure (Overbroad Results)

Query returns more rows/columns than intended.
Leaks private or unreleased data.
ex. A single search returns the full product table.

22
New cards

Unreleased Products / Hidden Data

Data present in the database but not meant for the public.
SQLi can reveal internal or future info.
ex. Upcoming products appearing in results.

23
New cards

Denial-of-Service via Huge Result Sets

Forcing queries to return massive data.
Slows the server and increases load.
ex. LIKE '%' / always-true conditions returning everything.

24
New cards

Plaintext Password

Password stored exactly as typed.
If stolen, it’s immediately usable.
ex. Database contains readable passwords.

25
New cards

Password Hashing

Storing a one-way transformed value instead of the real password.
Stolen hashes aren’t directly the original password.
ex. Database stores hash strings, not real passwords.

26
New cards

One-Way Hash

A function that’s easy to compute but hard to reverse.
Core idea behind secure password storage.
ex. You can verify matches, but can’t “unhash” easily.

27
New cards

Linux /etc/shadow (Concept)

System file that stores hashed passwords on many Linux systems.
Example of how passwords should be stored (hashed).
ex. Accounts have hashes, not plaintext passwords.

28
New cards

Web Request Flow (Browser → Server → Database)

Typical path: browser sends input → server turns it into DB actions → database runs query.
SQLi happens when server builds SQL from untrusted input.
ex. Form submit → server code → SQL query.

29
New cards

Server Layer (Hidden Part)

The backend that converts user input into database operations.
This is where you must defend against SQLi.
ex. Backend code building queries.

30
New cards

Database Layer (Executes Valid SQL)

The database runs any valid SQL it’s asked to run.
The DB won’t “know” the query is malicious.
ex. If the SQL is valid, it executes.

31
New cards

Guarding Against SQLi

Preventing user input from changing query meaning.
Stops data leaks and bypasses.
ex. Validation + safer coding + safe errors + audits.

32
New cards

Defense Strategy: Detection

Trying to catch bad input before it becomes SQL.
Blocks many attacks early.
ex. Input checks, regex checks, allowed-character rules.

33
New cards

Defense Strategy: Avoidance

Coding so damage is limited even if input is weird.
Reduces worst-case outcomes.
ex. Authentication must only return 0 or 1; anything else is error.

34
New cards

Input Validation

Checking input meets rules before using it.
Prevents “extra SQL” from sneaking in.
ex. Rejecting unexpected characters or formats.

35
New cards

Sanitizing Input

Cleaning/inspecting input so only safe data is used.
Main practical defense discussed in slides.
ex. Removing/rejecting quotes or disallowed symbols.

36
New cards

Responsibility Gap (Who Sanitizes?)

In multi-layer systems, each layer may assume another layer validated input.
Can result in nobody validating anything.
ex. “The layer before me will handle it” mindset.

37
New cards

Escape Characters

Characters that change how SQL interprets text (ex: quotes).
They let attackers break out of strings or change meaning.
ex. ' used to start/end strings.

38
New cards

Whitelist

“Only these characters are allowed.”
Stronger than blacklist for SQLi defense.
ex. Allow letters/numbers/space only.

39
New cards

Blacklist

“These characters are not allowed.”
Weaker—easy to miss something dangerous.
ex. Block a few symbols, attacker uses another one.

40
New cards

Regular Expression (Regex)

Pattern language for matching text.
Used to enforce whitelists on input.
ex. A pattern that flags invalid characters.

41
New cards

Regex Character Class [ … ]

Matches one character from a set.
Building blocks for input rules.
ex. [abc] matches a or b or c.

42
New cards

Regex Negated Class [^ … ]

Matches one character NOT in the set.
Great for detecting disallowed characters.
ex. [^0-9] matches any non-digit.

43
New cards

Regex Range (e.g., [a-z])

Matches any character in a range.
Lets you allow letters/digits easily.
ex. [0-9], [A-Za-z].

44
New cards

Whitelist Regex Example

Regex that flags characters outside allowed set.
Simple and practical SQLi detection.
ex. Anything not letter/number/space is invalid.

45
New cards

Invalid Query (Intentional Error)

Attacker sends input that breaks SQL.
Used to learn from error behavior.
ex. Wrong column name or broken quotes.

46
New cards

Error-Based Recon

Learning system details from raw error messages.
Errors can reveal DB type, tables, columns.
ex. Error mentions “MySQL”, table names, or column names.

47
New cards

Safe Error Handling

Showing generic errors instead of raw DB errors.
Stops info leaks that help attackers.
ex. “Something went wrong” instead of SQL stack trace.

48
New cards

Table Names / Attribute Names Leakage

Accidental reveal of schema details through errors.
Helps attackers craft better SQLi.
ex. Error references USERS table or Password column.

49
New cards

Code Audit

Actively looking through code for vulnerabilities.
Finds SQLi patterns before attackers do.
ex. Reviews + tools + tests focused on security.

50
New cards

Code Review

Humans inspect code changes.
Experienced devs spot risky patterns.
ex. Peer review catches string-built SQL.

51
New cards

Static Code Analysis

Tools scan code for known bad patterns.
Scales across big codebases.
ex. Tool flags unsafe query concatenation.

52
New cards

Penetration Testing (Pen Testing)

Controlled attempts to break into the system.
Tests real-world attack paths.
ex. Security team tries SQLi against endpoints.

53
New cards

Automated Testing

Tests that run automatically to catch issues.
Prevents regressions (bugs coming back).
ex. A test that fails if SQLi becomes possible again.

54
New cards

Regression (Security Regression)

A fixed bug reappears after changes.
Automated tests help prevent this.
ex. A later update reintroduces SQLi risk.

55
New cards

Real-Life SQLi: Sony (2011)

SQLi-associated breach affecting PlayStation accounts.
Shows scale of impact.
ex. Massive account compromise + major cost.

56
New cards

Real-Life SQLi: Heartland (2008)

SQLi-associated breach exposing huge numbers of card records.
Shows business and financial damage.
ex. Card data theft + large monetary loss.

57
New cards

Real-Life SQLi: Yahoo (2012)

SQLi-associated breach leaking many credentials.
Shows credential exposure risk.
ex. Email/password leak (and weak storage worsens it).

58
New cards

Concurrency

Multiple things happening “at the same time” (or overlapping in time).
In DBs: many users/transactions using the same data safely.
ex. Two users updating accounts while others are reading.

59
New cards

Parallelism

Work literally happening at the same time on multiple CPU cores.
Concurrency can exist without true parallelism.
ex. Two threads scheduled on one core vs two cores.

60
New cards

Process

A mostly independent unit of work managed by the OS.
Harder for one process to mess up another.
ex. Chrome vs Word running separately.

61
New cards

Thread

A mostly independent unit of work inside a process.
Threads share the process’s memory and code.
ex. A GUI thread and a main thread in one app.

62
New cards

Process vs Thread (key difference)

Processes are isolated; threads share a lot (heap, codebase).
Sharing makes threads faster to coordinate but easier to mess up.
ex. Two threads accidentally changing the same object.

63
New cards

Rise of threading (why it became common)

When clockspeeds stopped rising fast, CPUs added more cores.
To use cores, programs needed multiple things happening at once.
ex. Background work thread + UI thread.

64
New cards

Shared memory

Memory visible to multiple threads in the same process.
Anything shared and editable can cause bugs without sync.
ex. Two threads updating the same counter.

65
New cards

Resource (sync context)

Anything multiple threads/transactions might use.
Can be memory, file, object, row, table, etc.
ex. A work queue; a database row.

66
New cards

Synchronization

Regulating access to a shared resource.
Needed only when 2+ threads might access/modify the same resource.
ex. Locking before updating shared memory.

67
New cards

Serialize access

Forcing one-at-a-time access to a resource.
Prevents chaos, but reduces concurrency.
ex. Only one thread can pop from a queue at once.

68
New cards

Lock

A mechanism that blocks others from using a resource until released.
In code: mutex; in DBs: row/table locks.
ex. Transaction locks a row until commit/rollback.

69
New cards

Mutex

Mutual exclusion lock: only one thread can hold it at a time.
Other threads block until it’s unlocked.
ex. “Door” that lets one thread into a critical section.

70
New cards

Critical section

Code that touches shared data and must not interleave with others.
Protected with a lock.
ex. Pop from shared queue + update shared state.

71
New cards

Winner-take-all mutex

Regular mutex doesn’t care if you read or write—only one thread enters.
Simple but can block too much.
ex. Readers blocked even though they don’t change data.

72
New cards

Read-write lock

Two locks: read lock (many can hold) and write lock (only one).
No one can read while a write lock is held.
ex. Many readers of cached data; single writer for updates.

73
New cards

Read lock

Permission to read shared data.
Multiple readers allowed at once.
ex. Several users SELECT the same row.

74
New cards

Write lock

Permission to modify data.
Exclusive: blocks other reads and writes.
ex. UPDATE on a row blocks other access.

75
New cards

Lock contention

Multiple workers want the same lock.
Causes waiting and slower throughput.
ex. Many users updating the same hot row.

76
New cards

Over-synchronizing

Locking more than needed.
Can turn multithreaded behavior into single-threaded behavior.
ex. Locking everything “just in case.”

77
New cards

Race condition

Unsynchronized (or poorly synchronized) access that depends on timing.
Hard to spot because it only happens with “just wrong” timing.
ex. Two threads pop jobs and accidentally duplicate work.

78
New cards

Dueling writes

Two writers change the same value close together.
Last write “wins,” but result can be wrong or inconsistent.
ex. Two updates overwrite each other.

79
New cards

Simultaneous read/write problem

Reading while another thread writes can return an unpredictable value.
This is why we lock around modifications.
ex. Read gets half-updated state.

80
New cards

Work queue race example

Two threads both read the next job before either pops it.
Result: duplicate job processing and losing another job.
ex. T1 and T2 both “save” Job A, then pop A and B.

81
New cards

Deadlock

Two threads/transactions block each other forever.
Each holds a lock the other needs.
ex. T1 holds Lock A waiting for Lock B; T2 holds Lock B waiting for Lock A.

82
New cards

Deadlock symptom

No crash—things just stop.
Hard to debug without tools/timeouts.
ex. Requests hang forever.

83
New cards

Blocking

A thread/transaction is paused waiting for a lock.
It resumes when the lock is released.
ex. UPDATE waits for another transaction to commit.

84
New cards

Thread-safe

Safe to use with multiple threads at once without extra user locking.
Often handled by libraries/OS.
ex. Many memory allocators are thread-safe.

85
New cards

Thread dangers (core idea)

Threads can’t “watch” each other; you don’t know what others are doing.
Any shared editable data must be synchronized.
ex. Shared list modified without a lock.

86
New cards

Database as a process

A DBMS runs as a process and uses OS-level locking concepts.
DB users are like threads interacting with shared data.
ex. Many client connections acting at once.

87
New cards

Database user vs thread analogy

Users don’t know what other users are doing.
The database must keep them from hurting each other.
ex. Two users updating the same record.

88
New cards

Database lock

DB version of a mutex: prevents unsafe overlapping access.
Can be row/table/etc. depending on system.
ex. Lock a row during UPDATE.

89
New cards

Transaction

A group of SQL statements treated as one unit.
Changes are hidden until commit or undone by rollback.
ex. Transfer money: multiple statements but one transaction.

90
New cards

Commit

Finish a transaction and make its changes permanent and visible.
Also releases locks.
ex. After commit, other users can see updates.

91
New cards

Rollback

Cancel a transaction and undo its changes.
Also releases locks.
ex. Error occurs → rollback restores old values.

92
New cards

Autocommit

Each statement is its own transaction by default in some DBs.
Can reduce mistakes but loses multi-statement atomic behavior.
ex. Every UPDATE commits immediately unless you disable autocommit.

93
New cards

ACID

Properties transactions should satisfy: Atomicity, Consistency, Isolation, Durability.
Used to reason about correctness in multiuser DBs.
ex. Banking transfer must be correct even with many users.

94
New cards

Atomicity

All-or-nothing: either all statements happen or none do.
Also “appears to outsiders to happen all at once.”
ex. If transfer fails mid-way, no partial balances remain.

95
New cards

Consistency preservation

DB constraints/rules hold at start and end of a transaction.
No constraints violated after commit.
ex. Foreign keys still valid after changes.

96
New cards

Isolation

Transactions should act like they run separately even if they overlap.
One transaction shouldn’t see another’s partial work.
ex. Your SELECT shouldn’t change mid-transaction due to someone else.

97
New cards

Durability

After commit finishes, committed data cannot be lost.
Typically requires writing to disk and logging.
ex. Power loss after commit still keeps the update.

98
New cards

Transaction visibility

Other users can’t see a transaction “in progress.”
They see either the old state or the committed new state.
ex. Dirty reads should not happen.

99
New cards

Lost update

Two users update the same item; one overwrites the other.
Happens without proper locking/isolation.
ex. Account balance update disappears.

100
New cards

Dirty read

Reading a value written by a transaction that later rolls back.
You saw data that never truly “happened.”
ex. See temporary balance that gets undone.

Explore top flashcards