Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 1.75 KB

File metadata and controls

19 lines (12 loc) · 1.75 KB

9 Security and encryption

Security is important with Web application. This topic been getting more and more attention lately, especially in recent CSDN, Linkedin and Yahoo password leaks. As Go developers, we must be aware of vulnerabilities in our application and take precautions to prevent attackers from taking over our system.

Many Web application security problems are due to the data provided by a third-party. For example, user input should be validated and sanitized before being stored as secure data. If this isn't done then when the data is outputted to the client, it may cause a cross-site scripting attack (XSS). If unsafe data is used database queries, then it may cause a SQL injection. In sections 9.3, 9.4 we'll look at how to avoid these problems.

When using third-party data, including user-supplied data, first verify the integrity of the data by filtering the input. Section 9.2 describe how to filter input.

Unfortunately, filtering input and escaping output does not solve all security problems. We will explain in section 9.1 cross-site request forgery (CSRF) attacks. This is a malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts.

Adding encryption can also include the security of our Web application. In section 9.5 we will describe how to store passwords safely.

A good hash function makes it hard to find two strings that would produce the same hash value, which describes one way encryption. There is also two-way encryption, that is where you use a key to decrypt encrypted data. In section 9.6 we will describe how to perform one-way and two-way encryption.

Links

  • [Directory] (preface.md)
  • Previous Chapter: [Chapter 8 Summary] (08.5.md)
  • Next section: [CSRF attacks] (09.1.md)