Secure Programming and Source-Code Reviews - In the UNIX Environment. Thomas Biege <thomas@suse.de>



Similar documents
X05. An Overview of Source Code Scanning Tools. Loulwa Salem. Las Vegas, NV. IBM Corporation IBM System p, AIX 5L & Linux Technical University

Programming Flaws and How to Fix Them

Using etoken for SSL Web Authentication. SSL V3.0 Overview

Chapter 17. Transport-Level Security

Secure Shell SSH provides support for secure remote login, secure file transfer, and secure TCP/IP and X11 forwarding. It can automatically encrypt,

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

CMSC 421, Operating Systems. Fall Security. URL: Dr. Kalpakis

Lukasz Pater CMMS Administrator and Developer

SBClient SSL. Ehab AbuShmais

MatrixSSL Porting Guide

Criteria for web application security check. Version

Real-Time Communication Security: SSL/TLS. Guevara Noubir CSU610

[SMO-SFO-ICO-PE-046-GU-

Is Your SSL Website and Mobile App Really Secure?

VALLIAMMAI ENGINEERING COLLEGE

ERserver. iseries. Securing applications with SSL

Overview. SSL Cryptography Overview CHAPTER 1

EECS 354 Network Security. Introduction

Security Protocols/Standards

Computer Security CS 426. CS426 Fall 2010/Lecture 40 1

Security Technical. Overview. BlackBerry Enterprise Service 10. BlackBerry Device Service Solution Version: 10.2

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

Designing a Secure Client-Server System Master of Science Thesis in the Programme Software Engineering & Technology

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

CrashPlan Security SECURITY CONTEXT TECHNOLOGY

Certified Secure Web Application Secure Development Checklist

Secure Sockets Layer (SSL ) / Transport Layer Security (TLS) Network Security Products S31213

TLS/SSL in distributed systems. Eugen Babinciuc

Security Goals Services

Internet Programming. Security

SCP - Strategic Infrastructure Security

Network Security Part II: Standards

Intrusion detection for web applications

PCI Security Standards Council

Computer Networks. Network Security 1. Professor Richard Harris School of Engineering and Advanced Technology

Security Engineering Part III Network Security. Security Protocols (I): SSL/TLS

Software security specification and verification

SSL Tunnels. Introduction

Lecture 9: Application of Cryptography

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Forward Secrecy: How to Secure SSL from Attacks by Government Agencies

Introduction. Haroula Zouridaki Mohammed Bin Abdullah Waheed Qureshi

Chapter 10. Network Security

COMP 3704 Computer Security

Chapter 7 Transport-Level Security

CS 356 Lecture 23 and 24 Software Security. Spring 2013

CS5008: Internet Computing

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Secure Socket Layer (SSL) and Transport Layer Security (TLS)

CS 161 Computer Security Spring 2010 Paxson/Wagner MT2

Web Security: Encryption & Authentication

Overview SSL/TLS HTTPS SSH. TLS Protocol Architecture TLS Handshake Protocol TLS Record Protocol. SSH Protocol Architecture SSH Transport Protocol

HTTPS: Transport-Layer Security (TLS), aka Secure Sockets Layer (SSL)

Instructions on TLS/SSL Certificates on Yealink Phones

Communication Systems 16 th lecture. Chair of Communication Systems Department of Applied Sciences University of Freiburg 2009

Linux Operating System Security

CS 155 Final Exam. CS 155: Spring 2013 June 11, 2013

How to configure SSL proxying in Zorp 3 F5

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

DarkFS - An Encrypted File System

1 hours, 30 minutes, 38 seconds Heavy scan. All scanned network resources. Copyright 2001, FTP access obtained

Network Security - Secure upper layer protocols - Background. Security. Question from last lecture: What s a birthday attack? Dr.

BlackBerry Enterprise Solution

Savitribai Phule Pune University

Overview of CSS SSL. SSL Cryptography Overview CHAPTER

White Paper BMC Remedy Action Request System Security

Lecture 31 SSL. SSL: Secure Socket Layer. History SSL SSL. Security April 13, 2005

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Midterm 2 exam solutions. Please do not read or discuss these solutions in the exam room while others are still taking the exam.

Web Security Considerations

Secure Socket Layer/ Transport Layer Security (SSL/TLS)

From bsdtar to tarsnap

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ MEng. Nguyễn CaoĐạt

Security Technical. Overview. BlackBerry Enterprise Server for Microsoft Exchange. Version: 5.0 Service Pack: 4

CSE331: Introduction to Networks and Security. Lecture 32 Fall 2004

BlackBerry Enterprise Server 5.0 SP3 and BlackBerry 7.1

EXAM questions for the course TTM Information Security May Part 1

Communication Systems SSL

3.2: Transport Layer: SSL/TLS Secure Socket Layer (SSL) Transport Layer Security (TLS) Protocol

Web Plus Security Features and Recommendations

90% of data breaches are caused by software vulnerabilities.

Announcement. Final exam: Wed, June 9, 9:30-11:18 Scope: materials after RSA (but you need to know RSA) Open books, open notes. Calculators allowed.

Security. Learning Objectives. This module will help you...

Testing for Security

Spirent Abacus. SIP over TLS Test 编 号 版 本 修 改 时 间 说 明

E-commerce. Security. Learning objectives. Internet Security Issues: Overview. Managing Risk-1. Managing Risk-2. Computer Security Classifications

Appendix. Web Command Error Codes. Web Command Error Codes

Cryptosystems. Bob wants to send a message M to Alice. Symmetric ciphers: Bob and Alice both share a secret key, K.

Authentication Tokens

Security Protocols HTTPS/ DNSSEC TLS. Internet (IPSEC) Network (802.1x) Application (HTTP,DNS) Transport (TCP/UDP) Transport (TCP/UDP) Internet (IP)

Plan 9 Authentication in Linux

CS 416: Opera-ng Systems Design

Transcription:

Secure Programming and Source-Code Reviews - In the UNIX Environment Thomas Biege <thomas@suse.de>

What will I talk about? Application Design Programming Errors Cryptography and Randomness Secure Socket Layer (SSL aka TLS)

Application Design

A SetUID Application A Content Management System

A SetUID Application

Rules Just don t write it. Your Design is broken. ;-) Drop Privileges as early as possible. KISS Code Review... No, not by you.

The Bad Idea

Drop Privileges

Fork a Process

A Daemon

A Content Management System

Requirements remote Network Connections (TCP) a secure Channel (SSL) parallel Sessions Authentication (LDAP) create, open, edit HTML Files upload binary Files into a SQL Database view Documents (merge Files)

Overview

Programming Errors

Buffer Overflows Arithmetical Issues Race Conditions Format String Bugs Untrusted Input

Buffer Overflows

What to avoid? blindly using strcpy(), strcat(), sprintf() using strncpy(), strncat(), snprintf() with wrong Parameters ;-) Loops to copy Arrays w/o Bounds-Checking writing Functions with Array Parameter but w/o Array-Size Parameter trusting Input from uncontrolled/untrusted Sources... be paranoid!

Integer Overflows Type Mismatch Signed Issues

modular Arithmetic n!! mod 10 n = 9 n + 1 = 0

unsigned + 1 unsigned 1111 1111 0000 0000 signed type cast unsigned 1000 0001 1000 0001-32.767 32.767 signed type cast unsigned 1000 0001 1111 1111 1000 0001-32.767 4.294.934.529

What to take care off? Test for upper/lower Limits and Overflows Take Care: Overflows are undefined for signed Integers Be type-safe!

Race Conditions

Where? Filesystem multithreaded Code distributed Databases Signals and Interval Timer etc.

How to avoid them. use Filedescriptors not Filenames O_NOFOLLOW, O_CREAT O_EXCL setgid(2), initgroups(3), setuid(2) (Order!) fork(2) + drop Privileges mkstemp(3) mktemp(1) lock shared Resources while in use

Format String Bugs

published in Year 2000 printf-like Functions read: %x, %p write: %n (does not work since glibc of SUSE 10.1) wrong: snprintf(buf, sizeof(buf), user_data) right: snprintf(buf, sizeof(buf), %s, user_data)

Keyword Injection Cross-Site-Scripting Terminal Escape Sequences

You know it from...... SQL Injection... Shell Command Injection... LDAP Injection... and much more

Ok, what should I do? Filter untrusted Input White-List vs. Black-List a-za-z0-9\s is often sufficient use Escape-Functions, like mysql_ real_string_escape() avoid Functions that use the Shell, like popen(3), system(3), glob() (Perl), <> (Perl), etc.

What did I not tell you? Handling of confidential Information a poluted Process Environment Access Control List out of Control open Resources can be lost Resources Resource Limits, say No! to your Child(s) Tick Tack Timing Attacks

Cryptography and Randomness

Random Numbers max. Entropy: Hmax = 1, if P = 0,5 +/- e; for e = 0 statistical Randomness vs. cryptographical Randomness important Building Block for Algorithms and Protocols... but hard to find on a deterministic Machine

Random Numbers most Unix-like Systems provide /dev/random or /dev/ urandom read(2) instead of fread(3) (no Buffering/Read-Ahead) Usage of Hash Algorithms hide real Quality avoid PRNGs from Software Libraries if Kernel Support is not available use EGADS or EGD or: Counter-Mode Block-Cipher and a random IV

Secure Socket Layer SSL and TLS

Does and Donts SSL Version >= 3 (TLS) take care, some Algorithms are out-dated (DES) take care, Keys can be too small symmetric Ciphers: Key-Length >= 128 Bit asymmetric Ciphers: Key-Length >= 1024 Bit take care, exportable Ciphers are weak and not needed take care, never loose the Private-Key

Does and Donts use Ephemeral Keying = Perfect Forward Security (PFS) PRNG needs a random Seed SSL-Session Parameters need to be re-newed when big Amounts of Data are transfered (Hash Collisions, Wrap-Arounds of Seq. Numbers, etc.) Directory of CA-Certs should only be write-able by root (take care with LDAP Directories and alike) show the User as much Information as possible and at least: Verify the Certificates!

What Tools can I use for Code-Reviews freely available Scanners are a good Starting-Point (like RATS, ITS4, flawfinder,...) freely available Fuzzers find simple Bugs and cost Time grep to search in the Code cscope and kscope to navigate and to plot Call-Graphs a Text-Editor with Syntax-Highlighting Pad and Pencil document, verify, document, verify, document,...

http://www.suse.de/~thomas/papers/ Sicherheitsrelevante Programmierfehler Security Guidelines