SlideShare a Scribd company logo
Secure input and
output handling
How not to suck at data
validation and output
Anna Völkl / @rescueAnn
 Hi, I'm Anna. http://anna.voelkl.at
 I'm a Magento Certified Developer.
5 years Magento, Java/PHP since 2004
 I love IT & Telecommunication and IT- & Information-
Security. 
 I work at . Web Agency in Vienna/AT
What is Magento?
●
eCommerce Plaform
●
Initial release 2008
●
Varien  eBay  Permira private equity fund
●
Editions
– Community Edition (CE, Open Source)
– Enterprise Edition (EE)
●
Matthias Talk
– https://github.com/viennaphp/talks/blob/master/201505/01-outlook-on-magento-2.pdf
What is Magento?
http://blog.aheadworks.com/2016/03/magento-2-contributes-to-the-global-ecommerce-platforms-market/
Why is Magento cool?
●
Feature rich
●
Highly customizeable
●
Multiple stores/languages/currencies
●
Medium-large enterprises, Small-Business Team
●
Very active developer community
(magento.stackexchange.com, Twitter, Slack, IRC,
official Forum, Reddit,...)
●
Magento 2 ;-)
Magento 2
Magento 2 technology stack
●
Apache 2.x/Nginx 1.7+
●
PHP 5.5, 5.6x, 7.0
●
MySQL 5.6.x/MySQL Percona 5.6.x
●
Optional
– Varnish 3.x/4.x
– Redis 2.x/3.x, Memcache 1.4.x (Cache Storage)
– Solr 4.x (ElasticSearch planned)
Magento 2 technology stack
●
HTML 5, CSS 3 (LESS)
●
Jquery, RequireJS
●
Zend Framework 1, Zend Framework 2, Symfony
●
Coding standards PSR-0 (autoloading standard),
PSR-1 (basic coding standards), and PSR-2 (coding
style guide), PSR-3, PSR-4
●
Composer (dependency management)
Magento 2 testing
●
Automated testing suite
– Integration
– Functional areas
– Performance
●
PHPUnit (unit tests)
●
Selenium (functional tests)
Once upon a time...
academic titles?!
Teamwork also involves being a good teammate, which is why we are very proud
シャネル デコ
FC Barcelona and was presenting partner of the Fan Zone event prior to the gamehqn
Лечебные грязи Сакского озера
Trying to find for a approach to raise male power and endurance.
New year2013 best now41
Импотенция вы поглядите !
how to write an essay explaining why you deserve a scholarship
Sophisticated
Men
High-heeled shoes
A Wise Choice
http://onemilliondollarhomepage.ru/
how to write up divorce paper
write your name really cool
shady lady free download
driver samsung hd160jj p
Our daily business
Input

Process

Output
Security-Technology, Department of Defense Computer
Security Initiative, 1980
OWASP Top 10
1) Injection
2)Broken Authentication and
Session Management
3)Cross Site Scripting (XSS)
4)Insecure Direct Object
References
5)Security Misconfiguration
6)Sensitive Data Exposure
7)Missing Function Level
Access Control
8)Cross-Site Request Forgery
(CSRF)
9)Using Components with
known Vulnerabilities
10)Unvalidated Redirects and
Forwards
Stop „Last Minute Security“
●
Do the coding, spend last X hours on „making it
secure“
●
Secure coding doesn't really take longer
●
Data quality  software quality  security
●
Always keep security in mind
Every feature adds a risk.

Every input/output adds a risk.
http://blogs.technet.com/b/rhalbheer/archive/2011/01/14/real-physical-security.aspx
Input
Frontend input validation
●
User experience
●
Stop unwanted input when it occurs
●
Do not bother your server with crazy input
●
Only store, what you expect
Don't fill up your database with garbage.
Magento Frontend Validation
Magento 1 (51 validation rules)
js/prototype/validation.js
Magento 2 (74 validation rules)
app/code/Magento/Ui/view/base/web/js/lib/validati
on/rules.js
app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
min_text_length
max_text_length
max-words
min-words
range-words
letters-with-basic-punc
alphanumeric
letters-only
no-whitespace
zip-range
integer
vinUS
dateITA
dateNL
time
time12h
phoneUS
phoneUK
mobileUK
stripped-min-length
email2
url2
credit-card-types
ipv4
ipv6
pattern
validate-no-html-tags
validate-select
validate-no-empty
validate-alphanum-with-spaces
validate-data
validate-street
validate-phoneStrict
validate-phoneLax
validate-fax
validate-email
validate-emailSender
validate-password
validate-admin-password
validate-url
validate-clean-url
validate-xml-identifier
validate-ssn
validate-zip-us
validate-date-au
validate-currency-dollar
validate-not-negative-number
validate-zero-or-greater
validate-greater-than-zero
validate-css-length
validate-number
validate-number-range
validate-digits
validate-digits-range
validate-range
validate-alpha
validate-code
validate-alphanum
validate-date
validate-identifier
validate-zip-international
validate-state
less-than-equals-to
greater-than-equals-to
validate-emails
validate-cc-number
validate-cc-ukss
required-entry
checked
not-negative-amount
validate-per-page-value-list
validate-new-password
validate-item-quantity
equalTo
Add your own validator
define([
'jquery',
'jquery/ui',
'jquery/validate',
'mage/translate'
], function ($) {
$.validator.addMethod('validate-custom-name',
function (value) {
return (value !== 'anna');
}, $.mage.__('Enter valid name'));
});
M
2
M
2
<form>
<div class="field required">
<input type="email" id="email_address"
data-validate="{required:true, 'validate-
email':true}"
aria-required="true">
</div>
</form>
M
2
<form>
<div class="field required">
<input type="email" id="email_address"
data-validate="{required:true, 'validate-
email':true}"
aria-required="true">
</div>
</form>
M
2
<form>
<fieldset data-hasrequired="* Required Fields">
<input type="password"
data-validate="{required:true, 'validate-
password':true}" id="password" aria-
required="true">
<input type="password"
data-validate="{required:true,
equalTo:'#password'}" id="password-
confirmation" aria-required="true">
</fieldset>
</form>
M
2
<form>
<fieldset data-hasrequired="* Required Fields">
<input type="password"
data-validate="{required:true, 'validate-
password':true}" id="password" aria-
required="true">
<input type="password"
data-validate="{required:true,
equalTo:'#password'}" id="password-
confirmation" aria-required="true">
</fieldset>
</form>
M
2
Why frontend validation is not enough...
https://quadhead.de/cola-hack-sicherheitsluecke-auf-meinecoke-de/
Don't trust the user.
Don't trust the input!
Why validate input?
User form input
Database query results
Web Services
Server variables
Cookies
Validate input rules
Magento 1
Mage_Eav_Attribute_Data_Abstract
Magento 2
MagentoEavModelAttributeDataAbstractData
MagentoEavModelAttributeDataAbstractData
Input Validation Rules
– alphanumeric
– numeric
– alpha
– email
– url
– date
M
2
ZendValidator
Standard Validation Classes
Alnum Validator
Alpha Validator
Barcode Validator
Between Validator
Callback Validator
CreditCard Validator
Date Validator
DbRecordExists and
DbNoRecordExists
Validators
Digits Validator
EmailAddress
Validator
File Validation Classes
GreaterThan Validator
Hex Validator
Hostname Validator
Iban Validator
Identical Validator
InArray Validator
Ip Validator
Isbn Validator
IsFloat
IsInt
LessThan Validator
NotEmpty Validator
PostCode Validator
Regex Validator
Sitemap Validators
Step Validator
StringLength Validator
Timezone Validator
Uri Validator
Output
Is input validation not enough?
●
XSS
– Protect your users
– Protect yourself!
●
Store escaped data?
– Prepare the data where it's needed!
Use
$block->escapeHtml()
$block->escapeQuote()
$block->escapeUrl()
$block->escapeXssInUrl()
...also Magento does it!
$block->escapeHtml()
Whitelist: allowed Tags, htmlspecialchars
M
2
MagentoFrameworkEscaper
M
2
$block->escapeHtml()
Whitelist: allowed Tags, htmlspecialchars
$block->escapeQuote()
Escape quotes inside html attributes
$addSlashes = false for escaping js that inside html
attribute (onClick, onSubmit etc)
M
2
$block->escapeUrl()
Escape HTML entities in URL
(htmlspecialchars)
$block->escapeXssInUrl()
eliminating 'javascript' +
htmlspecialchars
M
2
Magento 2 Templates XSS security
<?php echo $block->getTitleHtml() ?>
<?php echo $block->getHtmlTitle() ?>
<?php echo $block->escapeHtml($block->getTitle()) ?>
<h1><?php echo (int)$block->getId() ?></h1>
<?php echo count($var); ?>
<?php echo 'some text' ?>
<?php echo "some text" ?>
<a href="<?php echo $block->escapeXssInUrl(
$block->getUrl()) ?>">
<?php echo $block->getAnchorTextHtml() ?>
</a>
Taken from http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/templates/template-security.html
Magento 2 Templates XSS security
●
Static Test: XssPhtmlTemplateTest.php in
devtestsstatictestsuiteMagentoTestPhp
●
See
http://devdocs.magento.com/guides/v2.0/frontend-
dev-guide/templates/template-security.html
magento dev:tests:run static
What happend to the little
attribute?
●
Weird customers and customer data was removed
●
Frontend validation added
•
Dropdown (whitelist) would have been an option too
●
Server side validation added
●
Output escaped
Summary
Think, act and design your software responsibly:
1) UTF-8 all the way
2) Client side validation, filter input
3) Server side validation
4) Data storage (database column size,...)
5) Escape output
6) Run tests
</happy>
Thank you!
Questions?
@rescueAnn
anna@voelkl.at

More Related Content

PDF
Secure input and output handling - Magento Meetup Vienna Edition
PDF
Secure input and output handling - Mage Titans Manchester 2016
PDF
Secure input and output handling - Meet Magento Romania 2016
PPTX
SydPHP Security in PHP
PPTX
Top 5 magento secure coding best practices Alex Zarichnyi
PPT
Developing Secure Applications and Defending Against Common Attacks
PDF
Magento Application Security [EN]
PPT
Jan 2008 Allup
Secure input and output handling - Magento Meetup Vienna Edition
Secure input and output handling - Mage Titans Manchester 2016
Secure input and output handling - Meet Magento Romania 2016
SydPHP Security in PHP
Top 5 magento secure coding best practices Alex Zarichnyi
Developing Secure Applications and Defending Against Common Attacks
Magento Application Security [EN]
Jan 2008 Allup

Similar to Secure input and output handling - ViennaPHP (20)

PDF
You wanna crypto in AEM
PPTX
Cqcon2015
PDF
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
PDF
Elevate london dec 2014.pptx
PDF
Become a Security Ninja
PPTX
Security engineering 101 when good design & security work together
PPT
WhiteHat Security Presentation
PPT
香港六合彩
PPTX
Web Application Penetration Testing Introduction
PDF
Wrangling Large Scale Frontend Web Applications
PPT
The Principles of Secure Development - David Rook
DOCX
Deb cover letter
PPT
Writing Secure Code – Threat Defense
DOCX
Robert polak matrix skills-web developer 2018-3
PPTX
2 . web app s canners
DOC
Resume
DOC
Prabhakar Kumar
PPT
Top Ten Web Application Defenses v12
PDF
GoralSoft
PDF
You wanna crypto in AEM
Cqcon2015
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
Elevate london dec 2014.pptx
Become a Security Ninja
Security engineering 101 when good design & security work together
WhiteHat Security Presentation
香港六合彩
Web Application Penetration Testing Introduction
Wrangling Large Scale Frontend Web Applications
The Principles of Secure Development - David Rook
Deb cover letter
Writing Secure Code – Threat Defense
Robert polak matrix skills-web developer 2018-3
2 . web app s canners
Resume
Prabhakar Kumar
Top Ten Web Application Defenses v12
GoralSoft
Ad

More from Anna Völkl (6)

PDF
Magento Live UK 2015: Security Essentials Seminar
PDF
Schnell, schön, sicher: Technische Konzeption und Betrieb sicherer E-Commerce...
PDF
Magento Security Best Practises - MM17PL
PDF
Magento Security Best Practises - MM17DE
PDF
Secure development environment @ Meet Magento Croatia 2017
PDF
Magento Application Security [DE]
Magento Live UK 2015: Security Essentials Seminar
Schnell, schön, sicher: Technische Konzeption und Betrieb sicherer E-Commerce...
Magento Security Best Practises - MM17PL
Magento Security Best Practises - MM17DE
Secure development environment @ Meet Magento Croatia 2017
Magento Application Security [DE]
Ad

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
top salesforce developer skills in 2025.pdf
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Digital Strategies for Manufacturing Companies
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
ai tools demonstartion for schools and inter college
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
assetexplorer- product-overview - presentation
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Nekopoi APK 2025 free lastest update
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Digital Systems & Binary Numbers (comprehensive )
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
top salesforce developer skills in 2025.pdf
Designing Intelligence for the Shop Floor.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Operating system designcfffgfgggggggvggggggggg
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Digital Strategies for Manufacturing Companies
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
ai tools demonstartion for schools and inter college
Internet Downloader Manager (IDM) Crack 6.42 Build 41
assetexplorer- product-overview - presentation
Understanding Forklifts - TECH EHS Solution
Nekopoi APK 2025 free lastest update
CHAPTER 2 - PM Management and IT Context
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo Companies in India – Driving Business Transformation.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf

Secure input and output handling - ViennaPHP