Filesystems timing attacks

Similar documents
Constant-time programming in C

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

VFS, Continued. Don Porter CSE 506

SOFTWARE ARCHITECTURE 2. FILE SYSTEM. Tatsuya Hagino lecture URL.

Operating System Labs. Yuanbin Wu

ECE 598 Advanced Operating Systems Lecture 18

File Management 1/34

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories

The bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage.

VIRTUAL FILE SYSTEM AND FILE SYSTEM CONCEPTS Operating Systems Design Euiseong Seo

Pointers, Pointers, Pointers!

Do not start the test until instructed to do so!

ECE 598 Advanced Operating Systems Lecture 14

RF-IDs in the Kernel -- Episode III: I want to File Away

17: Filesystem Examples: CD-ROM, MS-DOS, Unix

CSE 333 SECTION 3. POSIX I/O Functions

Files and Directories Filesystems from a user s perspective

Chapter Two File Systems. CIS 4000 Intro. to Forensic Computing David McDonald, Ph.D.

CS240: Programming in C

Xbox Security. Daniel Butnaru. 28 th June 2006

Files and the Filesystems. Linux Files

File System Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

The EXT2FS Library. The EXT2FS Library Version 1.37 January by Theodore Ts o

FILE SYSTEMS. Jo, Heeseung

Operating System Concepts Ch. 11: File System Implementation

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

File Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Systems Programming. 09. Filesystem in USErspace (FUSE) Alexander Holupirek

ANNOTATION FOR AUTOMATION: RAPID GENERATION OF FILE SYSTEM TOOLS

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems

CS 140 Project 4 File Systems Review Session

Addition of Ext4 Extent and Ext3 HTree DIR Read-Only Support in NetBSD

Filesystems in Linux. A brief overview and comparison of today's competing FSes. Please save the yelling of obscenities for Q&A.

Filesystems Overview

Operating System Labs. Yuanbin Wu

Sample Mid-Term Exam 2

File System Implementation

CS370 Operating Systems

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Software Architecture Division (SARD) Sony India Software Center Pvt Ltd. Copyright 2013 Sony Corporation

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand

CS , Spring Sample Exam 3

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

CS370 Operating Systems

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

CS G256 L07: Hash Functions May 25, 2004 MD5 SHA-1 HMAC

Programming refresher and intro to C programming

Author : admin. 1. Getting information about current file system partitions with fdisk and mount

Malloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016

File System Internals. Jo, Heeseung

Project 3 Help Document

Display Virtualization with KVM for Automotive Systems

Filename encoding. and case-insensitive filesystems. Gabriel Krisman Bertazi

The course that gives CMU its Zip! I/O Nov 15, 2001

Software Security: Buffer Overflow Attacks

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

Arrays intro (& strings) Ch 7

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

Open Source Used In c1101 and c1109 Cisco IOS XE Fuji

Inode. Local filesystems. The operations defined for local filesystems are divided in two parts:

Software Security: Misc and Principles

[6 marks] All parts of this question assume the following C statement. Parts (b) through (e) assume a variable called ptrs.

Emulation 2. G. Lettieri. 15 Oct. 2014

CS 161 Computer Security

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

ADVENTURE_IO Input/Output format and libraries for ADVENTURE modules List of Input/Output Functions February 17, 2006

Virtual File System. Don Porter CSE 306

CSE 451: Operating Systems. Sec$on 8 Project 2b wrap- up, ext2, and Project 3

// Initially NULL, points to the dynamically allocated array of bytes. uint8_t *data;

Recall: So What About a Real File System? Meet the inode: Recall: Unix File System (2/2) Recall: Unix File System (1/2)

CSE 333 SECTION 3. POSIX I/O Functions

CMD Code Walk through Wang Di

OPERATING SYSTEMS ASSIGNMENT 4 XV6 file system

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

File Checksums in Python: The Hard Way

CS527 Software Security

Mellanox Scalable Hierarchical Aggregation and Reduction Protocol (SHARP) API Guide. Version 1.0

System Programming And C Language

Secure Programming for the Desktop. Jiri (George) Lebl

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories

OPERATING SYSTEMS ASSIGNMENT 4 FILE SYSTEMS

dmrlib Documentation Release Wijnand Modderman-Lenstra

CSE 509: Computer Security

CS370 Operating Systems

Fundamentals of Computer Security

SA30228 / CVE

Today s Learning Objectives

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

Breaking cloud isolation

libtools Documentation

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm

Ext3/4 file systems. Don Porter CSE 506

Final Exam. Fall Semester 2016 KAIST EE209 Programming Structures for Electrical Engineering. Name: Student ID:

Files. Eric McCreath

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08

Section 11: File Systems and Reliability, Two Phase Commit

o Code, executable, and process o Main memory vs. virtual memory

Solution for Data Structure

Spiffy: Enabling File-System Aware Storage Applications

File System. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Transcription:

Filesystems timing attacks ZeroNights, Moscow, 08/11/13 research

Timing attacks basics time to execution of Function(UserData,PrivateData) depends from UserData and PrivateData this time can be use to determine PrivateData by UserData

Filesystems timing attacks What is Function(UserData,PrivateData)? Basically - STAT, but not only

FS timing attacks intro execution time of search operation depends on: search string data on which searches for attack concept is determine data by timings on different search strings

FS timing attacks intro execution time of search operation depends on: search string data on which searches for attack concept is determine data by timings on different search strings

Filesystems search basics Directory indexing mechanism list BTree (not binary tree) HTree + cache mechanism

Filesystem Directory indexing algo Hash type Cache ext2 list - + ext3/4 htree half_md4 + seed (earlier Legacy, TEA) + ufs2/nfs dirhash FNV (FreeBSD) DJB (OpenBSD) + FAT list (btree) - + NTFS btree - +

To cache or not to cache Cache does not prevent timing attacks Cache remove disk operations noises

ext2 lists To find a file, the directory is searched front-to-back for the associated filename HTree indexes were originally developed for ext2 but the patch never made it to the official branch. The dir_index feature can be enabled when creating an ext2 filesystem, but the ext2 code won't act on it.

ext2 lists./fs/ext2/dir.c: static inline int ext2_match (int len, const char * const name, struct ext2_dir_entry_2 * de) { if (len!= de->name_len) return 0; if (!de->inode) return 0; return!memcmp(name, de->name, len); } Timing anomaly for files with unexisting length

ext2 results 10 loops 100k STATS/loop Time(compared bytes)

OPTIMIZATION

ext3/4 HTree./fs/ext3/hash.c: ext3fs_dirhash * Returns the hash of a filename. If len is 0 and name is NULL, then * this function can be used to test whether or not a hash version is * supported. * * The seed is an 4 longword (32 bits) "secret" which can be used to * uniquify a hash. If the seed is all zero's, then some default seed * may be used.

ext3/4 HTree 4x32 bites = 16 bytes - impossible to brute force ;(./fs/ext3/hash.c: ext3fs_dirhash * Returns the hash of a filename. If len is 0 and name is NULL, then * this function can be used to test whether or not a hash version is * supported. * * The seed is an 4 longword (32 bits) "secret" which can be used to * uniquify a hash. If the seed is all zero's, then some default seed * may be used.

ext3/4 predicted seed Usefull while filesystem comes from firmware image All devices with same firmwares has the same seeds

What hash type used ext3/4? man tune2fs hash_alg=hash-alg Set the default hash algorithm used for filesystems with hashed b-tree directories. Valid algorithms accepted are: legacy, half_md4, and tea. half_md4 by default

ext3/4 MD4 hash tricks mkfs.ext3/4 seed from /dev/urandom p = name; while (len > 0) { (*str2hashbuf)(p, len, in, 8); half_md4_transform(buf, in); len -= 32; seed, 16 bytes (4x32 bits long) secret p += 32; } minor_hash = buf[2]; hash = buf[1]; break; 128 bit of state require to calculate next hashes

ext3/4 MD4 hash tricks MD4($salt.$filename) - really? If you know MD4($salt. a ) You know MD4($salt. a.$postfix) W/o knowledge about $salt value! What is $salt? Seed which unique for whole current filesystem (all folders)

ext3/4 legacy hash static u32 dx_hack_hash_signed(const char *name, int len) { u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; const signed char *scp = (const signed char *) name; while (len--) { hash = hash1 + (hash0 ^ (((int) *scp++) * 7152373)); if (hash & 0x80000000) hash -= 0x7fffffff; hash1 = hash0; hash0 = hash; } return hash0 << 1; }

Binary search for timing attack ext3_find_entry -> ext3_dx_find_entry -> dx_probe: p = entries + 1; q = entries + count - 1; while (p <= q) { m = p + (q - p)/2; dxtrace(printk(".")); if (dx_get_hash(m) > hash) q = m - 1; else p = m + 1; } 1. min_hash <= hash <= max_hash 2. (max-min)/2 <= hash 3.... T=T1+T2+T3+T4 T1 T2 T3 T4

ufs2/nfs FNV hash - no seed/salt! static inline Fnv32_t fnv_32_buf(const void *buf, size_t len, Fnv32_t hval) { const u_int8_t *s = (const u_int8_t *)buf; while (len--!= 0) { hval *= FNV_32_PRIME; hval ^= *s++; } return hval; }

ufs2/nfs DJB hash - no seed/salt! #define HASHINIT 5381 #define HASHSTEP(x,c) (((x << 5) + x) + (c)) hash32_buf(const void *buf, size_t len, uint32_t hash) { const unsigned char *p = buf; while (len--) hash = HASHSTEP(hash, *p++); return hash; }

UFS search by filename ufs_lookup -> ufs_lookup_ino: switch (ufsdirhash_lookup(dp, cnp>cn_nameptr, cnp->cn_namelen, &i_offset, &bp, nameiop == DELETE? &prevoff : NULL)) { case 0: ep = (struct direct *)((char *)bp->b_data + (i_offset & bmask)); goto foundentry; case ENOENT: i_offset = roundup2(dp->i_size, DIRBLKSIZ); goto notfound; default: break; ufsdirhash_lookup:... for (; (offset = DH_ENTRY(dh, slot))!= DIRHASH_EMPTY; slot = WRAPINCR(slot, dh->dh_hlen)) {... if (dp->d_namlen == namelen && bcmp(dp->d_name, name, namelen) == 0) { /* Found. Get the prev offset if needed. */ if (prevoffp!= NULL) { if (offset & (DIRBLKSIZ - 1)) { prevoff = ufsdirhash_getprev(dp, offset); if (prevoff == -1) { error = EJUSTRETURN; goto fail; } } else...

FAT/NTFS results BTree + binary search - no hashes, no problems ;) Just test using PoC from github

PoC Simple tool that can demonstrate timing anomaly Just PoC, not a framework Framework soon ;) https://github. com/wallarm/researches/blob/master/fstiming/fs-timing.c

Remote attacks Network noises Lack of opportunity to request multiple files in same loop But you can use additional features: CPU overload inodes count I think you know memory usage how to do it remotely ;)

Real case from a wild TFTP service Classic bruteforce w/o results Times to retrieve files are different Sort it! Find prefixes with anomaly timings: rom firmware. Brute filename after prefixes

Next steps And... YES! We want to optimize classic DirBusting technology For bruteforce to search through timing-attacks!

The end Contacts: @wallarm, @d0znpp http://github.com/wallarm no+sql timing attacks at: research