The Book Available On Amazon
Secure Development for Mobile Apps
不僅可以使水漂浮船,但它也可以下沉 -Not only can water float a boat, but it can sink it also.
Software can cause wealth to flow towards you, problems in software can also cause wealth to flow away from you. Therefore it pays to start right.
Understanding Secure Web Development
The popularity of mobile devices now makes programming mobile applications as critical as programming desktop browser applications were just yesterday. Social media goes hand in hand with being mobile and so the race is on to build better and better apps that do more and more with smaller and smaller screens. This means collecting data from various places in cyber-space, making it look great, and then sending data to various other places in cyber-space. What is this data? Where is it coming from? Where is it going? What is it actually doing? This is the security problem.
Headed somewhere fast
Building a mobile application almost always starts first with building a service that speaks HTML to manage the majority of the processing needs to occur, and the mobile app is then the client that renders the layout of this newly organized stream of cool data chaos. It is the job of the developer to know and account for this chaos, and to use all tools at his disposal to tame it into submission. It is a large task. Security depends on doing the correct thing at the right time, consistently, and that is what this book will endeavor to do: To leverage all tools available to help the developer in creating reusable code that is very consistent with security matters.
The goal of this book is to bridge the gap between understanding security problems and creating application designs that incorporate security from the beginning. There are many tools available to a PHP Developer in his fight against security attacks, and some of these tools might not be so obvious. These tools range from the built-in PHP language functions, Object-Oriented architecture constructs, software design patterns, and testing methodologies. Everyone one of these tools are established methods you can trust, and can all be combined in powerful ways to create reusable toolkits that make security an integrated part of the development process and not just an afterthought.
What Other Security Experts Have Said
What we need is a completely new way of thinking. A positive approach to secure programming...That’s why J.D. Glaser’s book is different. It’s about showing programmers the right way to do things.
- Jeremiah Grossman,
CEO WhiteHat Security
Adaptability, and understanding of “why”, which is what JD brings up when talking about security anti-patterns, pointing out towards the mindset, which is also introduced via change of thinking from "Clean, Safe, and Done” to "Reducing Attack Vectors", "Reduced Threats", "Less Vulnerable", "Higher Degrees of Protection” the latter ones pointing out the goals, which then, when followed on the different points of handling data, input can prevent even currently unknown attempts of attacks, the whats, to work.
- Jussi Jakanaho,
Former Chief Security Specialist Nokia,
ToolCrypt Group
Purchase on Amazon
If you don’t know of him by now you most certainly have used something in IT Security that he has had a direct or indirect influence on. As these defensive design patterns become more pervasive, we may actually see a fair fight in the war of cyber security. I’m grateful to J.D. for this contribution and I hope this book changes the way you go about building web application systems. -
Tim Keanini,
nCircle Security
Table of Contents
Chapter 1
- Introduction to Mobile Security Development
- Understanding Secure Web Development
- Applying Architecture Tools to Security
- Creating Consistent Reusable Code From Project to Project
- Mobile Application Using HTML5, AJAX and jQuery Mobile
- Mobile App - A Social Mashup
- Client Technologies
- Client Application Layout
- Server Application
- Evolution of Security Measures
- SQL Injection to XSS to CSRF
- Battle For Output Context
- New Technologies HTML5
- Bad Practices Invite Holes
- A New Mindset For Web Application Security -- ONLINE
Chapter 2
- The Attack Surface
- Attack Vectors
- Common Threats
- SQL Injection
- Cross-site Scripting
- Cross-site Request Forgery
- Session Hijacking
- Defending Input and Output Streams
- Theory Of Input Filtering and Output Escaping
- Input Validation
- Input Filtering
- Output Escaping
- You Must Know Where Your Data Is Displayed
- OWASP XSS Prevention Rules -- Online
Chapter 3 -- READ ONLINE
- Security Anti-Patterns
- Anti-Pattern #1
- Not Matching Data Character Set To Filter Character Set
- Misinformation Anti-Patterns
- The Mantra Anti-Pattern
- Critical Data Type Understanding and Analysis
- Single Data Type Anti-Pattern
- Validation By Type Process
- Input Same As Output Anti-Pattern
- The Assumed Clean Anti-Pattern
- Improper mysql_real_escape_string() Usage
- Filtering vs Escaping vs Encoding
- Only One Output Context Anti-Pattern
- Lack of Planning Ant-Patterns
- Lack of Consistency Anti-Patterns
- Lack of Testing Anti-Patterns
- Parameter Omission Anti-Pattern
- Design Practices Anti-Patterns
- No Clear Separation of HTML and PHP Code Anti-Pattern
- Too Many Database Function Calls
- Misleading Filtering Anti-Pattern
- Too Many Quotes Anti-Pattern
- Raw Request Variables As Application Variables
- Common Direct URL Input Anti-Pattern
- Poor Error Management Practices
- Poor Cryptography Practices
- Poor Cookie Expiration
- Poor Session Management
- Overcoming Anti-Patterns: Patterns, Testing, Automation
Chapter 4
- Essential Security Issues For Every Web Application
- A Consistent UTF-8 Character Set
- Clean Secure Data
- Input Validation: Account for Size and Type
- Escape Output: Account For Context
- Database Access Pattern
- Application Secrets Location Pattern
- Error Processing Pattern
- Error Logging Process Pattern
- Authentication Pattern
- Authorization Pattern
- White Listing Acceptable Input
- PHP Security Design Best Practices Summary
- Protect Secret Files/Protect Included Files
- Architect Input Validation
- Architect Output Escaping
- Architect Session Management
- Protect User Passwords
- Protecting User Session Data
- Protect Against CSRF Attacks
- Protect Against SQL Injection Attacks
- Protect Against XSS Attacks
- Protect Against File System Attacks
- Proper Error Handling
- OWASP Recommendations for PHP
- The Checklist
- Additional PHP Security Checklist
- Disable dangerous PHP functions
Chapter 5
- PHP Tools Overview
- Object Language support
- Abstract Classes, Interfaces, Templates, Strategy, Factories, Visitors
- Variable Variables: Power DRY
- Native Function support
- Encoding Functions
- The New PHP Escaping Class and Functions
- Header and Redirect Functions
- UTF-8 and Multi-Byte Functions
- DRY Enforcement Functions
- Type Enforcement Functions
- Filter Functions
- Mobile Functions
- Cryptography And Hashing Functions
- HTML Templating Support
- How To Inline HEREDOC Functions
- Best Practices Tips
- Issues to Avoid
- The Reason for PDO Prepared Statements
- Deprecated Security Functions
- Modern Crypto VS Old Crypto
Chapter 6
- A Complete UTF-8 Setup
- Why UTF-8
- UTF-8 Advantages
- UTF-8 Disadvantages
- How UTF-8 Effects Security
- Complete PHP UTF-8 Setup
- UTF-8 MySQL Database And Table Creation
- UTF-8 PDO Client Connection
- Manual UTF-8 PDO/MySQL Connection HowTo
- This will tell MySQLthat you are sending it UTF-8 data
- PHP UTF-8 Initialization And Installation
- UTF-8 Browser Setup
- Header Setup
- Metatag Setup
- Form Setup
- PHP UTF-8 Multi-Byte Functions
- UTF-8 Input Validation Functions
- UTF-8 String Functions
- UTF-8 Output Functions
- UTF-8 Mail
- UTF-8 Configuration PHPUnit Testing
- Test PHP Internal Encoding
- Test PHP Output Encoding
- PHPUnit Test Class for Asserting UTF-8 Configuration
Chapter 7
- A Working Project Template
- Every App Has Some Basic Similarities
- The Same Project Structure Issues
- The Same Security Issues
- A Project File And Layout Structure Template
- Project Layout Should Be Handled Consistently
- Select Query Wrapper
- Separation of HTML Static Resources
- The Completely Commented Files
- PHP PDO/UTF-8 Security Checklist
Chapter 8
- Separation of Concerns
- What Is Separation of Concerns
- Keep HTML As HTML
- Keep PHP out of HTML
- Keep JavaScript Out Of HTML
- Keep CSS out of JS
- Use of IDs and Facades
Chapter 9
- PHP and PDO
- PDO UTF 8 Connection
- MySQL UTF-8 Database and Table Creation Support
- PDO Prepared Statements
- Prepared Statement Examples
- Selecting Data and Placing into HTML and URL Context
- PDO SELECT Queries and Class Objects
- Quoting Values and Database Type Conversion
- PDO Manual Quoting Example
- PDO and WHERE IN Statements
- White Listing and PDO Quoting of Column Names
Chapter 10
- Template Pattern Forces Implementation
- Template Pattern Enforces Process
- Account Registration Template Part I - Registration
- Account Registration Template Part II -Activation
- Strategy Pattern for Output Escaping
- Escaping Strategy Class
- Improved Escaping Strategy Class
- The Input Cleaner Class
Chapter 11
- Modern PHP Encryption
- Using MCrypt For Two Way Encryption
- Encrypting Hashed Passwords With BlowFish
Chapter 12
- Professional Exception and Error Handling
- Configuring PHP Error Environment
- Secure php.ini and error log files
- Error Options Overview
- Production Error Configuration For php.ini
- Development Error Configuration For php.ini
- PHP Error Level Constants
- Exception Handling
- Introduction to Exceptions
- Trapping All Errors And Exceptions
- Converting Errors to Exceptions
- ErrorManager Class
- Handle Fatal Errors With register_shutdown_function()
Chapter 13
- Secure Session Management
- The SSL Landing Page
- Secure Session Overview
- Secure Session Management Checklist -- Online
- Session Checklist Details
- Setting Configuration And Setup
- Detecting Session Tampering
- Force Page Request Over SSL
- SSL Redirect
- Protocol Relative Links
Chapter 14
- Secure Session Storage
- PHP Default Session Storage Overview
- Session Storage Life Cycle
- AJAX and Session Locking
- Session Management Configuration
- Configure Security Before Session_Start() Is Called
- Properly Destroy Session
- Encrypted Session Storage
- Encrypted Session Storage Via MySQL
- Creating a Custom Session Handler in MySQL
- Class SecureSessionPDO
- Class SecureSessionPDO Details
- Encrypted Session Storage Via File System
- Class SecureSessionFile
- Class SecureSessionFile Details
Chapter 15
- Secure Forms
- Secure User Registration and Login Process Overview
- Unlimited Password Length, Unlimited Password Characters
- Secure Form Landing Pages Are Over SSL
- Secure Form Nonce – Prevent CSRF
- Class NonceTracker
- Class NonceTracker Listing
- Class NonceTracker Detail
- Form Input Validation Overview
- Registration Form
- Registration Form Details
- Double Encryption of User Passwords
- Account Management Class
- AccountManager Details And Authorization Checks
- Email Verification And Activation System
- Future Proof Encryption Strength With Blowfish Rounds
- Secure Password Request Link
- Reauthorize On Privilege Elevation
- Session Management Class
- SessionManagement Details
- Secure Logout Details Via SessionManager
- Privilege Elevation Protection System
- Secure Login
- Secure Login Form Details
- Protect Pages Via Authentication Check
- Secure Logout Page Details
- A Secure RememberMe Feature
Chapter 16
- PHP UTF-8 Input Validation
- Server UTF-8 Validation
- Validating UTF-8 Names and Emails Via RegEx
- PREG For PHP = PREG For JavaScript
- Server Side Regular Expressions
- JavaScript Validation VIA Regular Expressions
- JQuery Validation Via Regular Expressions
- JQuery Password Strength Meter
- JavaScript and JQuery Escaping And Filtering
- Replace innerHTML with innerText
- Embedded HTML HyperLinks
- Insecure JavaScript Functions
- Preventing Double Form Submission
- Post-Redirect-Get Pattern for Form processing
- The PRG Pattern
- The PRG Directive
- Tracking Form Tokens To Prevent Double Submission
- Controlling Form Page Caching And Page Expiration
- Time Stamping AJAX GET Requests
- Constructing Secure GET Request URLs
Chapter 17
- Secure File Uploading
- Basic Principles of Secure File Uploading
- Secure File Uploading To Database
- Retrieving Uploaded Images
Chapter 18
- Secure JSON
- Building Secure JSON Responses
- Proper JSON Construction Depends On Array Construction
- Safe Array Construction With PDO Records
- Send And Receive JSON In PHP
- Send JSON From PHP
- Receive JSON In PHP
- Parsing JSON Securely With JavaScript/JQuery
- JQuery JSON Calls
- Post and Parse JSON Response Example
Chapter 19
- GoogleMaps, YouTube, And JQuery Mobile
- Placing Videos Inside GoogleMap InfoWindows
- Creating InfoWindow Markers
- HTML And JQuery Mobile Layout
- Javascript File - gmap.js
- HTML Fragments Description
- HTML Fragments For InfoWindow
- YouTube Elements Description
- YouTube HTML Elements
- Map Functions
- JQuery Form Validation
- InfoWindow Marker With Playable Video
- Map Marker Database Table
- VideoMap URL Table
- Data Repository Class - GMapData
- Processing Markers
- Generating Markers
- Inserting And Updating Markers
- Preparing Safe JSON Data
Chapter 20
- Secure Twitter Proxy
- Twitter v1.1 Via PHP
- TweetFetcher Class
- Fetching v1.1 Tweets Via TweetFetcher
- Getting Twitter OAUTH Token
- Setting SSL Verification For CURL
- Retrieve Latest Tweets From Timeline
- Creating And Filtering Hyperlinks From Plain Text
- Filtering Bad Tweet Examples
- Examples of Secure Processing With processTweet()
- Using TweetFetcher
Chapter 21
- Secure AJAX Shopping Cart
- JQuery Mobile Store
- The Mobile Store
- Add Items To Cart
- Remove Items From Cart
- Making The PayPal Purchase
- Beginning The PayPal Transaction
- Securely Posting To PayPal
- Completing the PayPal Purchase
Chapter 22
- Common Facebook Canvas Vulnerability Points
- Saving Facebook RealTime Updates VIA PDO
- Reflecting JSON Coordinates
- Reflecting Messages
- Reflecting URLs
- JavaScript and JQuery Filters
- JSONP Precaution
Purchase on Amazon
上級醫生預防疾病;平庸醫生照顧即將到來的疾病;下級醫生治療實際的疾病 - The superior doctor prevents sickness. The mediocre doctor attends to impending sickness. The inferior doctor treats actual sickness.
There are many topics covered in the 420 pages of this book, along with many hard won tips to help you save time and create secure apps.
I hope you will have the confidence to purchase my book, and that it proves helpful to you.
Thank you.