The Need for Database Security
- Organizational databases tend to handle sensitive information
- Corporate financial data, Confidential phone records.. 등
- The reason for developing database security
- DBMS is very complex
- Sophisticated interaction protocol(SQL)
- SQL과 같은 고도화된 상호작용 프로토콜은 강력한 기능을 제공하지만, SQL ingection과 같은 공격에 취약할 수 있음
- 공격자가 악의적인 코드를 데이터베이스 쿼리에 삽입하여 민감한 정보에 접근하거나 데이터베이스 조작할 수 있음
- Heterogeneous mixture of database platforms with various OS platforms additional complexity
- 다양한 db 플랫폼, OS 플랫폼의 혼합은 추가적인 복잡성을 초래하여 취약점이 발생
- The increasing reliance on cloud technology to host part or all of the corportate databaser
- data 규모가 커지면서 outsourcing을 많이 하는데, 외부 클라우드 서비스 제공업체를 통해 데이터를 관리함으로써 보안 문제 발생
Database Management Systems
Databases
- Structured collections of data stored for use by one or more applications
- Contains the realationships between data items and groups of data items
- Can sometime contain sesitive data that needs to be secured
- Query language(SQL) provides a uniform interface to DB
DBMS(Database Management System)
- Suite(모음) of programs for constructing and maintaining the database
- Offers and hoc(임시의) query facilities to multiple users and applications
- DBMS Architecture
- DDL: Data definition language
- 데이터 베이스를 정의하는 언어로 데이터베이스 관리자나 데이터베이스 설계자가 사용
- create, alter, drop, truncate
- DML:Data manipulation language
- 데이터베이스 사용자가 응용 프로그램이나 질의어를 통해 저장된 데이터를 실질적으로 처리하는데 사용하는 언어
- select, insert, update, delete

DBMS Architecture
- DBMS typically must provide more detailed access control on data
- per table/per record/per column..
Relational Databases
-
Table of data consisting of rows and columns
column
: a particular type of data
row
: contains a specific value for each column
- Ideally has one column where all values are unique, forming an identifier/key for that row → primary key
-
Enables the creation of multiple tables linked together by foreign key
-
Use a relational query language(SQL) to access the database
- allows the user to request data that fit a given set of criteria
-
Relational Databse Elements
- Primary key
- Uniquely identifies a row
- Consists of one or more column names
- Foreign key
- Links one table to attributes in another
- View/virtual table
- Result of a query that returns selected rows and columns from one or more tables
-
Relational Database Example
- To create a relationship between two tables, primary key in one table must appear as attributes in another table

- View
- The result of a query that returns selected row and columns
Structured Query Language (SQL)
- Standardized Language to define schema, and to manipulate and query data in a relational database
- Serveral similar versions of ANSI/ISO standard
- All follow the same basic syntax and semantics
- SQL statements can be used to
- Create tables
- Insert and delete data in tables
- Create views
- Retrieve data with query statements
SQLi Injection Attacks
- One of the most prevalent and dangerous network-based security threat
- Designed to exploit the nature of Web application pages
- DB와 상호작용하는 과정에서 악의적인 SQL 명령어를 데이터베이스 서버로 보냄
- Sends malicious SQL commands to the database server
- Most common attack goal is bulk extraction of data
- Depending on the environment SQL injection can also be exploited to:
- Modify or delete data
- Execute arbitrary operating system commands
- Launch denial-of-service(DoS) attacks
Typical SQL Injection Attack
- Hacker finds vulnerability in web application
- Hacker injects an SQL command to a database through the web server and the web application server
- The database server returns confidential information to web application server after receiving malicious SQL codes
- The web application server generates web pages of the confidential information
- The web server sends the web pages to the hacker

The injection Technique
주입 기법은 문자열 조기 종료 및 새 명령어를 추가하여 실행
- The SQLi attack typically works by prematurely terminating a text string and appending a new command
- Because the inserted command may have additional strings appended to it before it is executed the attacker terminates the injected string with a comment mark “--”
- Subsequent text is ignored at execution time
- Simple example
- 원본 쿼리: OrdersTable에서 ShipCity 컬럼의 값이 ‘Redmond’인 모든 레코드를 선택
- 공격자가 주입한 쿼리: OrdersTable에서 ShipCity가 ‘Boston’인 레코드를 선택하려고 시도하고, OrdersTable 테이블 자체를 삭제하려고 시도 → 데이터 손실

SQLi Attack Avenues
- User input
- Attackers inject SQL commands by providing suitable crafted user input
- 조작된 사용자 입력을 제공함으로써 SQL 명령을 주입
- ex: 웹 폼, URL, 파라미터, 검색 창 등 사용자로부터 입력을 받는 모든 부분이 공격 대상이 될 수 있음
- 사용자 직접 공격과 즉각적 실행
- Server variables
- Attackers can forge the values that are placed in HTTP and network headers and exploit this vulnerability by placing data directly into the headers
- HTTP헤더와 네트워크 헤더에 포함된 값을 위조할 수 있음

- Second-order injection
- A malicious user could rely on data already present in the system or database to trigger an SQL injection attack, so when the attack occurs, the input that modifies the query to cause an attack does not come from the user, but from within the system itself
- 간접 공격과 지연된 실행
- User input을 통한 공격과 Secon-order injection의 차이 두 공격 방식의 주요 차이는 공격의 직접성과 실행 시점에 있습니다. 사용자 입력을 통한 SQL 인젝션은 사용자로부터 바로 악의적인 입력을 받아 실행되는 반면, 2차 주입은 시스템 내부에 저장된 데이터를 이용하여 나중에 실행되는 간접적인 공격 방식
- Cookies
- An attacker could alter cookies such that when the application server builds an SQL query based on the cookie’s content, the structure and function of the query is modified
- Physical user input
- Applying user input that consturcts an attack outside the realm of web requests
- ex) 2D barcode can contain malicious SQL statement
SQLi Attack types
InBand Attacks
- Uses the same communication channel for injecting SQL code and retrieving results
- The retrieved data are presented directly in application web page
- Include
- Tautology
- This form of attack injects code in one or more conditional statements so that they always so that they always evaluate to true

- End-of-line comment
- After injecting code into a particular field, legitimate code that follows are nullified through usage of end of line comments
- attaching comment ‘- -’를 통해 뒤의 내용을 주석 처리
- Piggybacked queries
- The attacker adds additional queries beyond the intended query, piggy-backing the attack on top of a legitimate request
- 세미콜론 뒤에 추가적인 쿼리를 추가해서 여러개의 쿼리가 실행되게 함
Inferential Attack
- The intent is to identify injectable parameters, extracing data, determining data schema
- Done by sending particular requests and observing the resulting behavior of the Website/database server
- Include
- Illegal/logically incorrect queries
- This attack lets an attacker gather important information about the type and structure of the backend database of a Web application
- The attack is considered a preliminary, information-gathering step for other attacks
- Blind SQL injection
- Allows attackers to infer the data present in a database system even when the system is sufficiently secure to not display any erroneous information back to the attacker
- Example
- Blind SQL injection
- 첫번째 쿼리: 이쿼리는 항상 거짓이 되는 조건을 포함함. 이는 공격자가 데이터베이스가 정상적으로 작동하고 있으며, SQL 쿼리가 실행되고 있음을 확인하는데 사용될 수 있음
- 두번째 쿼리: 항상 참이 되는 조건을 포함하여, login=’legalUser’인 사용자의 accounts 정보를 반환함
- 첫번째 쿼리와 두번째 쿼리의 결과를 비교해 공격자는 데이터 베이스가 특정 조건에 따라 어떻게 반응하는지 관찰하여 정확한 정보를 추론할 수 있음
- Illegal/logically incorrect queries
- We can find the first character in the first tuple of sysobjects using binary search


SQLi Countermeasures
- Defensive coding
- Manual defensive coding practices
- Parameterized query insertion
- SQL 쿼리에 사용자 입력을 직접 삽입하는 대신, 매개변수를 사용하는 것
- SQL DOM
- Detection
- Signature based
- Anomaly based
- Code analysis
- Run-time prevention
- Check queries at runtime to see if they conform to a model of expected queries
Database Access Control
- determines if the user has access to the entire database or just portion of it
- determines what access rights the user has(create, insert, delete, update, read, write)
- Can support a range of administrative policies
- Centralized administration
- Small number of privileged users may grant and revoke access rigits
- Ownership-based administration
- The creator of a table may grant and revoke access rights to the table
- Decentralized administration
- The owner of the table may grant and revoke authorization rights to other users, allowing them to grant and revoke access rights to the table
SQL-based Access Definition

Role-Based Access Control
- Role-based access control eases administrative burden and improves security
- Database is often used for dozens of applications, unlike a file for a few applications
- Common categories of database users
- Application Owner
- An end user who owns database objects as part of an application
- End user
- An end user who operates on database objects via a particular application but does not own any of the database objects
- Administrator
- User who has administrative reponsibility for part or all of the database
- A database RBAC needs to provide the following capabilities:
- Create and delete roles
- Define permissions for a role
- Assign and cancel assignment of users to roles
- Example: Microsoft SQL Server
- Supports three types of roles: server roles, database roles, and user-defined roles → First two of them are “Fixed-roles”
- Fixed server roles
- To ease the administrative tasks by spreading the administrative responsibilities
- Fixed database roles
- To assist a DBA with delegating administrative responsibilities
- User defined roles
- Standard role/Application role(password require)

Inference
- The process of performing authorized queries and deducing unauthorized information from the legitimate responses received
- 허가된 쿼리를 수행하고, 받은 정당한 응답으로부터 무단 정보를 추론하는 과정
- 데이터베이스 또는 정보 시스템에 대한 접근이 제한된 환경에서, 공격자가 허가된 방식으로 정보를 조회하고, 그 응답을 분석함으로써 보호된 정보나 민감한 데이터를 간접적으로 유추하는 기법
- Depending on distribution of data, even small information about target user can make the inference attack successful

Inference Detection
데이터베이스 내의 민감한 정보가 비민감한 정보를 통해 간접적으로 유추될 수 있는 가능성을 방지하거나 감지하는 기술
- Inference detection during database design
- Approach removes an inference channel by altering the database structure or by changing the access control regime to prevent inference
- Techniques in this category often result in unncessarily stricter access controls that reduce availability
- 필요 이상으로 엄격한 접근 제어를 초래하여 데이터의 가용성을 감소시킬 수 있음
- Inference detection at query time
- Approach seeks to eliminate an inference channel violation during a query or series of queries
- If an inference channel is detected, the query is denied or altered
→ Some inference detection algorithm is needed
→ Progress has been in devising specific inference detection techniques for multilevel secure databases and statistical databases
- Example
- Clerks가 relation between Salary and name을 모르게 하려면?
- create 3 tables → Employees(Emp#, Name, Address), Salaries(S#, Salary), Emp-Salary(Emp#, S#)
- Clerks only can access Employees and Salaries, not Emp-Salary
- 만약 StartDate를 Salaries에 추가한다면?
- 간접적인 정보 추론이 가능 → 근무기간과 급여의 관련성, Salaries 테이블 내에서 특정 StartDate가 유일하게 존재한다면, 그 날짜와 관련된 급여 정보가 특정 직원에게 속할 가능성이 높아짐

K-anonymity and L-diversity
- K-anonymity
- Eventhough hacker know 3 specific values, can not know what row is associated because several rows would be matched
- 어떤 정보를 통해서도 특정 개인을 K명 중 한 명으로만 식별할 수 있게 만드는 것 → 익명성 보장

- L-diversity
- K-anonymity를 수행해서 여러 row가 매칭되게 하더라고, target output이 같은 값이라면 inference가 성공하게됨
- Critical column should not provide same output to hacker can not determine the target
- 익명화된 데이터 내에서도 민감한 정보의 다양성을 보장하는 것에 초점을 맞추어, 어떤 준식별자 그룹 내에서도 민감한 정보가 L개 이상의 다양한 값을 가져야 함

Data Encryption
- The database is typically the most valuable information resource for any organization
- Protected by multiple layers of security
- Firewalls, authentication, general access control systems, DB access control systems, database encryption
- Encryption becomes the last line of defense in database security
- Can be applied to the entire database, at the record level, the attribute level, or level of the individual field
- Disadvantages to encryption
- Key management
- Authorized users must have access to the decryption key for the data for which they have access
- Inflexibility
- When part or all of the database is encrypted it becomes more difficult to perform record searching
Outsourcing Encrypted Database Scenario
- Data owner
- organization that produces data to be made available for controlled release
- User
- human entity that presents queries to the system
- Client
- frontend that transforms user queries into queries on the encrypted data stored on the server
- Server
- on organization that receives the encrypted data from a data owner and makes them available for distribution to clients

- encrypting entire database
- encrypting core component in quries
- encryption of entire tuple with additional indices to help querying
- level of range로 나타냄, 다 encrypt 하지 않고, abbrevaited information about each column → 특정값을 알아도 exact matching 어려움

Data Center Security
Data center
- An enterprise facility that houses a large number of servers, storage devices, and network switches and equipment
- The number of servers and storage devices can run into the tens of thousand in one facility
- Generally includes redundant or backup power supplies, redundant network connections, environmental controls, and various security devices
- Can occupy one room of a building, one or more floors, or an entire building
Key Data Center Elements
- Stacks of servers and storage modules(서버 및 저장 모듈)
- Individual modules equipped with 10Gb~40Gb ethernet ports
- To handle massive traffic → 대량의 트래픽 처리 가능
- Top of Rack(TOR) switches
- 서버 랙 상단에 위치함
- Server access switch (서버 액세스 스위치로 작동)
- Operating 100Gbps to support the interconnection of server racks → 100Gbps의 속도로 운영되어 서버 랙 간의 상호 연결을 지원

Data Center Security Consideration
- Data Security
- Encryption, Password policy, Secure IDs, Data Protection, Data masking, Data retention 등
- Network Security
- Firewalls, Anti-virus, Intrusion detection/prevention, Authentication 등
- Physical Security
- Surveillance, Mantraps, Two/three factor authentication, Security zones등
- Site Security
- Setbacks, Redundant utilities Landscaping, Buffer zones, Crash barriers, Entry points 등
TIA-492
- Telecommunications Infrastructure Standard for Data Centers
- 데이터 센터를 위한 통신 인프라 표준. 이는 데이터 센터 설계 및 운영에 있어 중요한 기준을 제공하며, 효율적이고 신뢰성 높은 데이터 센터 구축을 목표로 함
- TIA-492 compliant data center showing key function areas
- TIA-492에 준수하는 데이터 센터는 다음과 같은 주요 기능 영역을 포함해야 함
- 주요 영역 리스트
- Entrance Room (입구 구역): 데이터 센터로 들어오는 외부 통신선들이 모이는 곳입니다. 이곳은 외부 통신 네트워크와 데이터 센터 내부 네트워크 간의 첫 번째 연결점 역할을 합니다. 입구 구역은 주로 외부에서 온 전화 및 데이터 통신선을 받아들이고, 필요한 경우 이를 내부 시스템으로 전달하는 장비를 포함합니다.
- Main Distribution Area (MDF, 메인 분배 구역): 데이터 센터의 핵심 통신 장비가 설치되는 중심 영역입니다. 중앙 스위치, 서버, 메인 프레임 컴퓨터 등과 같은 핵심 네트워크 장비와 시스템을 수용합니다. MDF는 데이터 센터의 전반적인 네트워크 구조와 통신 흐름을 관리합니다.
- Horizontal Distribution Area (HDA, 수평 분배 구역): 작업 공간이나 특정 층 등과 같은 구체적인 영역으로 네트워크 연결을 제공하는 곳입니다. HDA는 통신 케이블이 메인 분배 구역에서 각 사용 지점까지 연결되는 경로를 제공합니다.
- Equipment Distribution Area (EDA, 장비 분배 구역): 특정 서버, 스토리지 시스템 및 네트워크 장비와 같은 IT 장비를 수용하는 공간입니다. EDA는 데이터 센터 내에서 특정 작업이나 서비스를 수행하기 위해 설정된 장비들의 집합지입니다.
- Zone Distribution Area (ZDA, 존 분배 구역): 데이터 센터 내의 특정 구역 내에서 네트워크 연결을 제공하는 데 사용됩니다. ZDA는 보통 특정 작업 영역이나 데이터 센터의 특정 부분에 서비스를 제공하기 위해 설계됩니다.
- Computer Room (컴퓨터 룸): 서버, 스토리지, 네트워크 장비 및 기타 중요 IT 장비를 수용하는 주요 공간입니다. 컴퓨터 룸은 데이터 센터의 핵심 연산과 데이터 처리 작업이 이루어지는 곳으로, 고도의 환경 제어(온도, 습도, 청정도 등)가 필요합니다.

Data Center Tiers Defined in TIA-942
- 티어 1: 기본적인 사이트 인프라를 가진 데이터 센터로 단일 경로를 통해 전력과 냉각을 제공하며, 이로 인해 예정된 유지보수 작업 시 시스템을 비활성화해야할 수 있음
- 티어 2: 예정된 유지보수 작업을 수행하는 동안에도 시스템이 계속 작동할 수 있도록 함. 그러나 비계획적인 사고로 인해 시스템이 중단될 가능성은 여전히 존재
- 티어 3: 동시에 유지보수가 가능한 사이트 인프라를 갖춘 데이터 센터. 여러 경로를 통해 전력과 냉각을 제공하지만, 동시에는 하나의 경로만 활성화됨. 비계획적인 사고에 대해서도 내결함성을 가지고 있음
- 티어 4: 완전한 내결함성을 가진 사이트 인프라를 갖춘 데이터 센터. 모든 시스템에 대해 이중화된 경로를 제공하며, 하나의 경로에 문제가 발생해도 다른 경로를 통해 서비스가 계속 유지될 수 있음을 의미