SlideShare a Scribd company logo
1 of 27
Download to read offline
開發人員該知道?	 
·•資訊安全觀念	 CIA	 
·•資訊安全策略	 3A	 
·•環境設定與工具	 
·•資安程式開發
Confidentiality	

!

Integrity	

!

Availability
Authentication	

!

Authorization	

!

Accounting
Secure Coding
Guidelines
• Avoid duplication	

• Restrict privileges	

• Establish trust boundaries	

• Minimize the number of permission checks	

• Encapsulate
Denial of Service
• Release resources in all cases	

• "Zip bombs"	

• "Billion laughs attack"	

• "Log bombs"	

• Infinite loops: "Messages poison”	

• Resource limit checks should not suffer from
integer overflow
Confidential Information
• Purge sensitive information from
exceptions	


• Do not log highly sensitive information	

• Consider purging highly sensitive from
memory after use
Injection & Inclusion
• Avoid dynamic SQL	

• SQL Injection	

• XML and HTML generation requires care	

• Cross Site Scripting(XSS)	

• Restrict XML inclusion	

• XML External Entity (XXE)
Accessibility & Extensibility
• Limit the accessibility of classes, interfaces,
methods, and fields.	


• Limit the accessibility of namespace.	

• Isolate unrelated code.	

• Limit the extensibility of classes and methods.	

• Understand how a superclass can affect
subclass behavior.
Accessibility & Extensibility

Reducing the "attack surface" of the code
Input Validation
• Validate inputs	

• 有效值	

• 特殊字元:URL / HTML / XML
Mutability
• Prefer immutability for value types	

• Create copies of mutable output values	

• Make public static fields as constants	

• Do not expose mutable statics
Object Construction
• Avoid exposing constructors of sensitive
classes	


• Prevent the unauthorized construction of
sensitive classes	


• Prevent constructors from calling methods
that can be overridden
Serialization & Deserialization

• Avoid serialization for security-sensitive
classes	


• Guard sensitive data during serialization	

• View deserialization the same as object
construction
Access Control
• Understand how permissions are checked	

• Beware of callback (Lifecycle) methods	

•

Callback methods are generally invoked from the system
with FULL permissions	


• Be careful caching results of potentially
privileged operations
Security	 Coding	 涵蓋了?
·•Authentication	 &	 Authorization	 
·•Session	 &	 State	 management	 
·•Input	 &	 Output	 
·•File	 Handling	 
·•Error	 Handling	 
·•Auditing	 &	 Logging	 
·•Cryptography	 
·•Configuration
Application Logging Tips
使⽤用適當⼯工具
資訊分級
• ERROR 	

• WARN 	

• INFO 	

• DEBUG 	

• TRACE
到底在Log啥?
Debug.WriteLine("Returning orders: {0}", orders);
if(MyLog.isDebugEnabled()){	

MyLog.Debug("It's a secret!”);	

}
避免副作⽤用!
try {	

	

 MyLog.Trace("Id=" + request.getUser().getId() );	

	

 MyLog.Trace("Accesses " + manager.getPage().getUrl().toString());	

} 	

catch(Exception e) {	

}
簡潔描述!
if(message is TextMessage)	

	

 //...	

else	

MyLog.Warn("Unknown message type");
精確調整輸出格式!

時戳
等級 程式名稱 訊息 	

{0:HH:mm:ss} {1}
{2}
{3}
記錄⽅方法參數與回傳值!
public String printDocument(Document doc, Mode mode) {	

MyLog.Debug("Entering printDocument(doc={0}, mode={1})", doc, mode);	

String id = //...	

MyLog.Debug("Leaving printDocument(): {0}", id);	

return id;	

}
記錄例外狀況資訊!
MyLog.Error("IO exception", e);	

throw new MyCustomException(e);
易於解讀!
MyLog.Debug("Request TTL set to: {0} ({1})", new DateTime(ttl), ttl);	

// Request TTL set to: Wed Apr 28 20:14:12 CEST 2010 (1272478452437)	

!

String duration =
DurationFormatUtils.formatDurationWords(durationMillis, true, true);	

MyLog.Info("Importing took: {0}ms ({1})", durationMillis, duration);	

// Importing took: 123456789ms (1 day 10 hours 17 minutes 36 seconds)
Summary

·•Use	 for	 daily	 log	 or	 tracing	 
·•Audience	 
·•Easy	 to	 read	 
·•Easy	 to	 analysis	 
·•Will	 it	 cause	 error?	 
·•System	 performance	 issue
Why Secure Coding Training is Important?

Cost%

Cost%of%fixing%security%flaws%during%different%development%phases%

Phases%
Fixing&bugs&by&releasing&a&patch&costs&60&6mes&more&than&fixing&the&same&bug&during&the&design&stage.&
Source:&h"p://www.auto.tuwien.ac.at0

More Related Content

Similar to Security coding

Similar to Security coding (20)

Secure all things with CBSecurity 3
Secure all things with CBSecurity 3Secure all things with CBSecurity 3
Secure all things with CBSecurity 3
 
Secure software development presentation
Secure software development presentationSecure software development presentation
Secure software development presentation
 
What Does a Full Featured Security Strategy Look Like?
What Does a Full Featured Security Strategy Look Like?What Does a Full Featured Security Strategy Look Like?
What Does a Full Featured Security Strategy Look Like?
 
Cyber Security and Cloud Computing
Cyber Security and Cloud ComputingCyber Security and Cloud Computing
Cyber Security and Cloud Computing
 
Api days 2018 - API Security by Sqreen
Api days 2018 - API Security by SqreenApi days 2018 - API Security by Sqreen
Api days 2018 - API Security by Sqreen
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top Ten
 
Intro to Apache Shiro
Intro to Apache ShiroIntro to Apache Shiro
Intro to Apache Shiro
 
How to Destroy a Database
How to Destroy a DatabaseHow to Destroy a Database
How to Destroy a Database
 
Info sec final
Info sec finalInfo sec final
Info sec final
 
Architecting for Microservices Part 2
Architecting for Microservices Part 2Architecting for Microservices Part 2
Architecting for Microservices Part 2
 
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
 
Tänased võimalused turvalahendustes - Tarvi Tara
Tänased võimalused turvalahendustes - Tarvi TaraTänased võimalused turvalahendustes - Tarvi Tara
Tänased võimalused turvalahendustes - Tarvi Tara
 
The What, Why, and How of DevSecOps
The What, Why, and How of DevSecOpsThe What, Why, and How of DevSecOps
The What, Why, and How of DevSecOps
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)
 
Ved du, hvor dine data er - og hvem, der har adgang til dem? Ron Ben Natan, I...
Ved du, hvor dine data er - og hvem, der har adgang til dem? Ron Ben Natan, I...Ved du, hvor dine data er - og hvem, der har adgang til dem? Ron Ben Natan, I...
Ved du, hvor dine data er - og hvem, der har adgang til dem? Ron Ben Natan, I...
 
Vulnerable Active Record: A tale of SQL Injection in PHP Framework
Vulnerable Active Record: A tale of SQL Injection in PHP FrameworkVulnerable Active Record: A tale of SQL Injection in PHP Framework
Vulnerable Active Record: A tale of SQL Injection in PHP Framework
 
Bsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicatedBsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicated
 
Crash Course In Brain Surgery
Crash Course In Brain SurgeryCrash Course In Brain Surgery
Crash Course In Brain Surgery
 
Java EE Security API - JSR375: Getting Started
Java EE Security API - JSR375: Getting Started Java EE Security API - JSR375: Getting Started
Java EE Security API - JSR375: Getting Started
 

More from BITs Information Technology Consultants Co., Ltd. (10)

00 android開發課程大綱
00 android開發課程大綱00 android開發課程大綱
00 android開發課程大綱
 
Mod04 analysis designphase
Mod04 analysis designphaseMod04 analysis designphase
Mod04 analysis designphase
 
Mod03 architecture phase
Mod03 architecture phaseMod03 architecture phase
Mod03 architecture phase
 
Mod02 requirements phase
Mod02 requirements phaseMod02 requirements phase
Mod02 requirements phase
 
Mod00 agenda
Mod00 agendaMod00 agenda
Mod00 agenda
 
Mod01 sdlc
Mod01 sdlcMod01 sdlc
Mod01 sdlc
 
Android labs part2
Android labs part2Android labs part2
Android labs part2
 
Android labs part1
Android labs part1Android labs part1
Android labs part1
 
iOS程式撰寫通則
iOS程式撰寫通則iOS程式撰寫通則
iOS程式撰寫通則
 
Objective c design pattens-architetcure
Objective c design pattens-architetcureObjective c design pattens-architetcure
Objective c design pattens-architetcure
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Security coding