Input Validation Course

Now that you understand the need for mobile app security, you should learn how to implement the most fundamental security mechanism of all: input validation.

5 hours, 23 minutes

Course description

Lack of input validation is the single most commonly cited mistake that mobile app developers make. Corrupt or manipulated input lies at the root of most malicious hacking exploits. As a mobile app developer, you need to know how to defend your app and the user's data from attack. In this course you will learn which characters can be misinterpreted as commands, and how to render those characters harmless. You will practice using a number of input sanitization and techniques including regular expressions and Swift functions. You'll defend against SQL injection, understand the larger scope of cross-site scripting and cross-site request forgeries, and validate the identity of a website API whose content your app consumes. You will also learn how to defend against unexpected attack vectors such as QR codes and deserialized JSON objects.

Syllabus

Activity: Protecting users against insecure UIWebView

Video - 00:11:00

In this segment, we test the UIWebView vulnerability for ourselves.
WebView protection

Video - 00:05:00

In this segment, we study the infamous UIWebView vulnerability, including full code and results of the exploit. We also discuss how to protect against the UIWebView vulnerability.
Activity: Securely working with JSON, part 2

Video - 00:09:00

In this activity, we continue with the previous app to learn about the underlying mechanism of using an API key to make a call to a server and how to utilize it in our app.
Activity: Securely working with JSON

Video - 00:13:00

In this activity, we learn how to deserialize incoming data from a server and display it in our app.
Activity: Installing Alamofire and SwiftyJSON pods

Video - 00:04:00

In this activity, we learn how to use CocoaPods to install the external libraries we will use to work with JSON.
Object deserialization

Video - 00:07:00

In this segment, we learn what it means to serialize and deserialize and object from Swift to JSON. We learn about the risks of deserialization and how to protect against those risks.
SQL injection, part 2

Video - 00:04:00

In this segment, we examine server-side SQL stored procedures as another mechanism to protect against SQL injection.
SQL injection

Video - 00:11:00

In this segment, we learn about SQL injection, including the basics of the SQL language and the code involved in a SQL injection exploit. We learn how to mitigate this risk in SQLite by parameterizing queries.
Activity: Filtering a malicious QR code, part 2

Video - 00:06:00

In this activity, we conclude our exercise into filtering malicious content from a QR code.
Activity: Filtering a malicious QR code

Video - 00:12:00

In this activity, we work with the original malicious QR code responsible for exploiting the notorious iOS 11 camera app vulnerability. We learn how to filter malicious content from a QR code, thus rendering the exploit harmless.
Code injection

Video - 00:15:00

In this segment, we learn about malicious code injection of various types, including SQL, directory traversal, null terminating bytes, JSON, HTML and XML strings, script tags in HTML, and QR codes. We also learn best practices to protect against client-side injection attacks.
Activity: Exploring XSS attacks

Video - 00:10:00

In this activity, we explore the mechanisms of cross-site scripting and the potential damage it can cause.
Cross-site attacks

Video - 00:12:00

In this segment, we learn about cross-site scripting and cross-site request forgery attacks, and how to protect against them.
Null bytes

Video - 00:07:00

In this segment, we learn about the dangers of null bytes, how they are represented in different programming languages, how they are used in poison null byte attacks and how they are mitigated in Swift.
Activity: Sanitizing input with a property wrapper

Video - 00:07:00

In this activity, we continue to work with property wrappers to sanitize input.
Activity: Value clamping with a property wrapper

Video - 00:07:00

In this activity, we continue to practice with property wrappers to clamp values to upper and lower boundaries.
Activity: Trimming whitespace and newlines with a property wrapper

Video - 00:07:00

In this activity, we use a Swift playground to practice using property wrappers to trim out whitespaces and newlines.
Property wrappers

Video - 00:09:00

In this segment, we learn about the new Swift 5.1 feature called property wrappers. We learn how to use property wrappers to clamp values, trim whitespace and newlines and sanitize input.
Activity: Sanitizing input, part 2

Video - 00:14:00

In this activity, we continue working with input sanitization in our mobile app.
Activity: Sanitizing input

Video - 00:11:00

In this activity, we practice sanitization of various text input fields in our Swift mobile app.
Activity: Regular expressions, part 3

Video - 00:08:00

In this activity, we continue with our Swift playground to test US Social Security numbers and number formats for popular credit cards.
Activity: Regular expressions, part 2

Video - 00:07:00

In this activity, we continue with our Swift playground to match international phone numbers, URLs and emails.
Activity: Regular expressions

Video - 00:08:00

In this activity, we use a Swift playground with NSPredicate to test various regex filters to match password requirements and US/Canada phone numbers.
Input sanitization - Regular expressions, part 2

Video - 00:07:00

In this segment, we conclude our study of regular expressions, including examining some practical examples used in Swift.
Input sanitization - Regular expressions

Video - 00:08:00

In this segment, we continue our study of how to use regular expressions, including escaping characters and practical everyday examples.
Input sanitization

Video - 00:13:00

In this segment, we learn what input sanitization is and how to achieve it using the filter() method and regular expressions in Swift.
Activity: Playing with format strings

Video - 00:10:00

In this activity, we practice working with format strings in Swift.
Format string attack, part 3

Video - 00:07:00

In this segment, we learn how format strings can be abused by attackers. We examine the most common NSString parameters that are used in format string attacks. We also learn which C, Core Foundation and Cocoa functions are the most vulnerable to format string attacks.
Format string attack, part 2

Video - 00:09:00

In this segment, we continue our study of format strings in Swift.
Format string attack

Video - 00:08:00

In this segment, we learn what format strings are and work with examples in Swift.
Special characters, Part 2

Video - 00:07:00

In this segment, we continue our exploration of Swift 5.1 raw strings. We also examine what Unicode scalar values are and list how to deal with unsafe characters.
Special characters

Video - 00:14:00

In this segment, we examine what special characters are and the risk they pose when included in an input string. We also learn about string literals in Swift and how to escape special characters. We are also introduced to raw string examples in Swift 5.1.
Activity: Disabling AutoCorrection

Video - 00:11:00

In this activity, we practice disabling autocorrection in Swift.
AutoCorrect and AutoFill

Video - 00:11:00

In this segment, we examine the specific risks associated with iOS autocorrection and autofill, and how to programmatically address those risks.
Understanding input risks

Video - 00:14:00

In this segment, we learn the difference between trusted and untrusted data, as well as how to identify and diagram trust boundaries both within and outside our app.

Meet the author

Chrys Thorsen

Chrys Thorsen is a technology and education consultant with 25 years of experience. Her work has taken her around the U.S. and overseas, including as a contractor for the CDC using technology to help fight HIV/AIDS in Africa.

During her career, she has acquired 40 IT certifications, authored over 25 textbooks on a wide range of IT subjects, including secure iOS and Android coding, and created an equal number of IT-related video courses. When not working, Chrys enjoys reading scientific articles and experimenting with Internet-of-Things devices. She currently lives in Virginia with her sister, her cat and her dog which, as she describes it, "have the worst sibling rivalry imaginable."

Unlock 7 days of free training

  • 1,400+ hands-on courses and labs
  • Certification practice exams
  • Skill assessments

Associated NICE Work Roles

All Infosec training maps directly to the NICE Workforce Framework for Cybersecurity to guide you from beginner to expert across 52 Work Roles.

  • All-Source Analyst
  • Mission Assessment Specialist
  • Exploitation Analyst

Plans & pricing

Infosec Skills Personal

$299 / year

  • 190+ role-guided learning paths (e.g., Ethical Hacking, Threat Hunting)
  • 100s of hands-on labs in cloud-hosted cyber ranges
  • Custom certification practice exams (e.g., CISSP, Security+)
  • Skill assessments
  • Infosec peer community support

Infosec Skills Teams

$799 per license / year

  • Team administration and reporting
  • Dedicated client success manager
  • Single sign-on (SSO)
    Easily authenticate and manage your learners by connecting to any identity provider that supports the SAML 2.0 standard.
  • Integrations via API
    Retrieve training performance and engagement metrics and integrate learner data into your existing LMS or HRS.
  • 190+ role-guided learning paths and assessments (e.g., Incident Response)
  • 100s of hands-on labs in cloud-hosted cyber ranges
  • Create and assign custom learning paths
  • Custom certification practice exams (e.g., CISSP, CISA)
  • Optional upgrade: Guarantee team certification with live boot camps

Learn about scholarships and financing with

Affirm logo

Award-winning training you can trust