C++ and Programming Language Vulnerabilities

Slides:



Advertisements
Similar presentations
For C Language WG, 2006 March, Berlin 1 A New Standards Project on Avoiding Programming Language Vulnerabilities Jim Moore Liaison Representative from.
Advertisements

Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 10: Buffer Overflow.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 20 Slide 1 Critical systems development.
On the Relation between Design Contracts and Errors Karlstad University Computer Science On the Relation Between Design Contracts and Errors A Software.
Chapter 1 Principles of Programming and Software Engineering.
(c) 2007 Mauro Pezzè & Michal Young Ch 1, slide 1 Software Test and Analysis in a Nutshell.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Design Synopsys System Verilog API Donations to Accellera João Geada.
Software Dependability CIS 376 Bruce R. Maxim UM-Dearborn.
Procedure specifications CSE 331. Outline Satisfying a specification; substitutability Stronger and weaker specifications - Comparing by hand - Comparing.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
Chapter 6 Buffer Overflow. Buffer Overflow occurs when the program overwrites data outside the bounds of allocated memory It was one of the first exploited.
Department of Computer Science A Static Program Analyzer to increase software reuse Ramakrishnan Venkitaraman and Gopal Gupta.
Ranga Rodrigo. The purpose of software engineering is to find ways of building quality software.
Software Development. Software Developers Refresher A person or organization that designs software and writes the programs. Software development is the.
Software Testing Yonsei University 2 nd Semester, 2014 Woo-Cheol Kim.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Static Program Analyses of DSP Software Systems Ramakrishnan Venkitaraman and Gopal Gupta.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Quality Assurance.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
Pointers. Variable Declarations Declarations served dual purpose –Specification of range of values and operations –Specification of Storage requirement.
Design Principles and Common Security Related Programming Problems
Refactoring Agile Development Project. Lecture roadmap Refactoring Some issues to address when coding.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 17 – Specifications, error checking & assert.
Principles of Programming & Software Engineering
Examples (D. Schmidt et al)
CSE3302 Programming Languages (notes continued)
Data Abstraction: The Walls
CMSC 345 Defensive Programming Practices from Software Engineering 6th Edition by Ian Sommerville.
Protecting Memory What is there to protect in memory?
Chapter 1 Computer System Overview
Regression Testing with its types
Why study programming languages?
Types for Programs and Proofs
Protecting Memory What is there to protect in memory?
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Protecting Memory What is there to protect in memory?
Andy Wang Object Oriented Programming in C++ COP 3330
Component Based Software Engineering
Programming Language Vulnerabilities within the ISO/IEC Standardization Community Stephen Michell International Convenor JTC 1/SC 22 WG 23 Programming.
Principles of Programming and Software Engineering
About the Presentations
Magento Technical Guidelines Eugene Shakhsuvarov, Software Magento
Object-Orientated Programming
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Database Performance Tuning and Query Optimization
Levels of Software Assurance in SPARK
CSCI 3370: Principles of Programming Languages Chapter 9 Subprograms
Chapter 9 :: Subroutines and Control Abstraction
Chapter 12: Computer Programming
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Covering CWE with Programming Languages and Tools
Baisc Of Software Testing
Language-based Security
Chapter 11 Database Performance Tuning and Query Optimization
Chapter 1 Computer System Overview
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Foundations and Definitions
Chapter 8 - Design Strategies
Testing & Security Dr. X.
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Design Contracts and Errors A Software Development Strategy
Presentation transcript:

C++ and Programming Language Vulnerabilities Stephen Michell Convenor of ISO/IEC/JTC 1/SC 22/WG 23 Programming Language Vulnerabilities stephen.michell@csagroup.org stephen.michell@maurya.on.ca

Outline History of WG 23 Edition 3 Outlook Compare with Ada Changes from Edition 2 What are programming language vulnerabilities? Vulnerability examples Documenting C subset of C++ Working with WG 23

History of WG 23 ISO/IEC/SC22/WG23 Programming Language Vulnerabilities Formed in 2006 to address mistakes in programs that can lead to attacks or faults the can cause application and system failures Published first Technical Report TR 24772 Guidance in avoiding programming language vulnerabilities through language selection and use in 2010 Identified and documented vulnerabilities in a general way WG 23 was working on programming language specific annexes, but none were ready Published edition 2 in 2013 Contained annexes for Ada C Python PHP Ruby Spark

Edition 3 Outlook Slight name change Dropping “through language selection and use” Move the language-specific annexes from the document Put separate parts too difficult to keep all language-specific annexes in sync for a single publication cycle Base document becomes 24772-1 Ada guidance becomes 24772-2 C guidance becomes 24772-3 Python guidance becomes 24772-4 Fortran guidance becomes 24772-8 Expect ballot to start in 2018

Edition 3 Outlook (cont) Others (Spark, Ruby, PHP, etc) in 1-3 years Planning a C++ Part, hopeful Rationale  C++ is being increasingly used in places where the safety and security of the application matter. C++, like all programming languages, provides capabilities to developers and makes choices that leave applications open to programming errors or attacks that can be detrimental to systems or users that depend on the application. The TR explains the vulnerability, its possible consequences, and ways to avoid it.

Compare with Ada Ada is known as a “safe language” Yet TR 24772-2 Very strong type system Robust compile-time and runtime checking Yet TR 24772-2 Acknowledges 50 (out of 63) vulnerabilities as having applicability to Ada. Most of the rest are acknowledged if an identified, small set of unsafe features of the language are used. The guidance to users helps to avoid or mitigate the vulnerabilities 

Changes from edition 2? Added a few new vulnerabilities Deep vs Shallow Copying Violations of the Liskov Substitution Principle Redispatching Polymorphic Variables 3 vulnerabilities (in clause 7) on time-related issues Moved some vulnerabilities to clause 7 no language-related implications or mitigations in clause 7 Fault tolerance and failure strategies Distinguished values in data types Added a top-N guidance in clause 5 Not a coding standard, but a collation of the most common (and important) guidelines that apply to many vulnerabilities in clauses 6 & 7

What are Programming Language Vulnerabilities? Every application program exists on a machine with constrained resources Fixed word size and formats mean that some operations will always overflow, overflow or wrap around And sometimes it is not an error Fixed memory size and or long-lived programs mean that we must reuse memory locations. This leads to reusing variables, releasing and reallocating memory, sharing or reinterpreting data in other contexts

What are Programming Language Vulnerabilities? (cont) Every programming language contains features that: Permit data regions to be sized, resized, allocated, destroyed Permit data to be reinterpreted Permit data to be created in one type and arbitrarily changed to another Permit algorithms to be prematurely terminated or arbitrarily extended Permit the arbitrary input, interpretation and output of data over arbitrary I/O channels Each expose the application to the risk that the capability will be misused in a way that could adversely affect the system that relies upon the application.

What are Programming Language Vulnerabilities? (cont) Programming languages can/have been devised that minimize or mitigate the risks, but cannot eliminate them. Where an attacker has sufficient knowledge of the application, or the OS environment, or the communications protocols, or the timing order of application components, or the order of access to external resources, then attacks can be constructed that will compromise the system.

Example – Buffer Overflow A classic vulnerability in C C IO (old style) does not enforce the buffer size of an array (say an array of characters) very often, the developer makes assumptions about input data and does not check dynamically. Unrestricted input can overflow the buffer and write new data or instructions into neighbouring buffers or onto the stack, resulting in program failure or even arbitrary code execution. C++ provides mechanisms to mitigate or eliminate the defect. Buffers can be placed into classes and access restricted via methods that can be shown to obey the size limitations of the buffer. Guidance would be to always encapsulate data elements into classes and restrict access to the buffer to methods of the class.

Example – Liskov Substitution Principle Present in all object-oriented languages. Each method at the root of a hierarchy needs to specify the strongest preconditions that are required to call any extension of the method, a the weakest postcondition that the method or any of its derivatives will deliver. Each extension of a method must Weaken the preconditions Strengthen its delivery guarantees the postconditions Failure is that implementors do not understand the principle and override a method with one that has stronger preconditions or weaker postconditions Guidance is to forbid such strentheneing/weakening, use static analysis tools, etc.

About “safe” languages Almost all “real” languages are dramatically “pruned” when used in projects with stringent needs for security or safety Witness JSF coding rules for C++ or MISRA Witness Spark subset of Ada Removes all access types (pointers), generics, polymorphism, generalized tasking, functions with side effects, calendar clock, atomic data There is no weakness in documenting the vulnerabilities in a language and recommending approaches and techniques to avoid them

Documenting C subset of C++ - a proposed approach TR 24772-3 already fully documents the C subset With a couple of exceptions where C++ changed C++ Part must recognize the subset and the way that it is used C++ Part should not restate the C Part, but should reference it. Make a simple statement that the appropriate vulnerabilities as documented in TR24772-3 clause 6.x exists in C++ Document features that share that vulnerability (if applicable) Document C++ features that mitigate or avoid the vulnerability Recommend that these be used instead Where C++ changes a C language feature, Document the impact of the changes on any related C vulnerabilities Document new or changed vulnerabilities

Working with WG 23 WG 23 is willing to How can we work together? Let WG 21 lead with the documentation of vulnerabilities in C++ Lead and ask WG 21 for technical assistance How can we work together?