Secure Coding Flashcards

1
Q

Solution for SQL Injection

A

Solution
* Limit input size
* Remove special character
* Remove reserved keywords
* Check the desired pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Solution for XML injection

A
  • Limit inputs
  • Check it has the pattern that you want
  • Never work on or log unvalidated inputs (string, path,…)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Numbers
Overflow

A

The built-in integer operators in Java secretly wrap the result without
reporting overflow when a mathematical operation cannot be represented
using the provided integer types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Solution for Number Overflow

A

Solutions:
* Upcasting: Consider a larger data type if possible
* Prediction testing: Find the boundaries, throw ArithmaticException when needed.
* BigIntger: Convert the inputs into objects of type BigInteger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Numbers
Precision

A

Solution:
* Use integer
* Use BigDecimal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Methods

A

Validate input parameters
* Might be costly
* Avoid inconsistent computation, runtime exceptions

Assertion
- test your assumptions about your program

Accessibility
* Method that check security should be private or final.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Defensive Programming

A

Minimise the scope of variables

Minimise the accessibility of classes

Wrapper methods
* Use private modifiers when it is possible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Conclusive Secure Coding

A
  • Do not trust inputs from users
  • Take extra consideration when dealing with sensitive information
  • Do not save them in local (log)
  • Save them encoded when possible
  • Be aware of scopes
  • Limit modifier as much as possible
  • Limit the scope of each variable
  • Be aware of bitwise operations and overflow
How well did you know this?
1
Not at all
2
3
4
5
Perfectly