Software have bugs

소프트웨어에는 늘 버그가 존재한다. 경험에서 알 수 있듯이, 내가 짠 코드가 한번에 의도대로 실행되는 경우는 드물다.

 

Low-level Languages and Software Security

  • C/C++같은 Low-level languages는 성능을 위해 type safety와 memory safety에 대한 위험 성을 안고 간다.
    • 이러한 책임은 프로그래머들에게 있다.
  • 많은 양의 레거시 소프트웨와 성능이 중요한 소프트웨어들은 C/C++로 쓰여져있다.
  • 올바르게(manually) 찾아서 고치기엔 너무 많은 버그들이 존재한다.

 

Memory Safety

메모리 안전성은 모든 메모리 접근이 프로그래밍 언어 소스에서 정의된 방식을 고수한다고 보장하는 성질 이다.

만약 프로그램에서 모든 가능한 실행이 memory safe하다면 그 프로그램은 memory safe하다.

 

Spatial Memory Safety

Spatial Memory Safety는 모든 메모리 dereferences가(주소로부터 값에 접근하는 것) 그들 포인터의 유효한 objects의 범위 내에서 수행되는 것을 보장하는 성질이다. (Spatial memory safety is a property that ensure that all memory dereferences are within bounds of their pointer's valid objects.)

 

Spatial Memory Corruption

...
char array[10]; // array of 10 chars
array[10] = 'a'; // ???
...

이것은 memory corruption을 일으키는 spatial memory bug의 본질적인 케이스이다.

 

Temporal Memory Safety

Temporal memory safety는 모든 메모리 dereferences(주소를 통한 값 접근)이 유효한 시간에 행해지는 것을 보장하는 것이다. (Temporal memory safety is a property that ensure that all memory dereferences are valid at the time of the dreference.)

 

Temporal Memory Corruption

int * bar() {
  int a = getRandomNumber(); // a = 77;
  int *p = &a;
  return p;
}
​
void foo() {
  int *p = bar();
  somefunc();
  someOtherfunc(*p);
}
  • Use-After-Free: 가장 흔한 temporal memory corruption 형태이다.

 

Type Safety

Type Safety는 type system의 규칙을 위반하지 않는 연산들만 수행됨을 보장하는 것이다. (Type Safety ensures that only the operations that do not violate the rules of the type system are allowed.)

 

Safe Programming Language

  • 현대의 high-level languages는 memory-safety와 type-safety를 제공한다.
  • Memory Safe, Strongly-typed languages에는 python, java, rust 등이 있다.

 

Software Exploitation

  • Memory corruption은 프로그램에 정의되지 않은 행동들을 발생시킨다.
  • 프로그램 실행은 프로그래밍 로직의 의도를 벗어나고 그 행동은 기존 소스 코드랑 전혀 다르게 된다.
  • 버그가 발생한 후 프로그램 상테를 제어하여 나쁜 행동을 할 수 있을까?

 

Control-Flow Hijacking

  • 소프트웨어 버그를 사용하여 프로그램의 상태 또는 수행을 가로채 임의의 연산들을 실행하는 행위이다.
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기