SQL ATTACK

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/56

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.

57 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).