[ODOP:18]패킷 분석 실습 > TLS 1.3

지금까지 학습 한 내용을 토대로 wireshark 를 이용하여 패킷 분석을 실습 해 보는 내용을 담고 있습니다

Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
        Version: TLS 1.0 (0x0301)
        Length: 2050
        Handshake Protocol: Client Hello
            Handshake Type: Client Hello (1)
            Length: 2046
            Version: TLS 1.2 (0x0303)
            Random: 2e5590bb6dffb2d46a8785916da357a76d106fdb2fea9c4e3e79e07f920422eb
            Session ID Length: 32
            Session ID: fd6e99a6a54c774f4a935028d8270fc33a6c33650dbfd729da86b4854770f0b5
            Cipher Suites Length: 32
            Cipher Suites (16 suites)
                Cipher Suite: Reserved (GREASE) (0xfafa)
                Cipher Suite: TLS_AES_128_GCM_SHA256 (0x1301)
                Cipher Suite: TLS_AES_256_GCM_SHA384 (0x1302)
                Cipher Suite: TLS_CHACHA20_POLY1305_SHA256 (0x1303)
                Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b)
                Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)
                Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (0xc02c)
                Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030)
                Cipher Suite: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca9)
                Cipher Suite: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca8)
                Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)
                Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)
                Cipher Suite: TLS_RSA_WITH_AES_128_GCM_SHA256 (0x009c)
                Cipher Suite: TLS_RSA_WITH_AES_256_GCM_SHA384 (0x009d)
                Cipher Suite: TLS_RSA_WITH_AES_128_CBC_SHA (0x002f)
                Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA (0x0035)
            Compression Methods Length: 1
            Compression Methods (1 method)
            Extensions Length: 1941
            Extension: Reserved (GREASE) (len=0)
            Extension: ec_point_formats (len=2)
            Extension: signed_certificate_timestamp (len=0)
            Extension: compress_certificate (len=3)
            Extension: signature_algorithms (len=18)
            Extension: key_share (len=1263) X25519Kyber768Draft00, x25519
            Extension: encrypted_client_hello (len=282)
            Extension: extended_master_secret (len=0)
            Extension: application_layer_protocol_negotiation (len=11)
            Extension: supported_groups (len=12)
            Extension: renegotiation_info (len=1)
            Extension: status_request (len=5)
            Extension: supported_versions (len=7) TLS 1.3, TLS 1.2
            Extension: server_name (len=27) name=msgstore.www.notion.so
            Extension: session_ticket (len=0)
            Extension: psk_key_exchange_modes (len=2)
            Extension: Reserved (GREASE) (len=1)
            Extension: pre_shared_key (len=235)
            [JA4: t13d1516h1_8daaf6152771_0d365e64def3]
            [JA4_r: t13d1516h1_002f,0035,009c,009d,1301,1302,1303,c013,c014,c02b,c02c,c02f,c030,cca8,cca9_0005,000a,000b,000d,0012,0017,001b,0023,0029,002b,002d,0033,fe0d,ff01_0403,0804,0401,0503,0805,0501,0806,0601]
            [JA3 Fullstring: 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,11-18-27-13-51-65037-23-16-10-65281-5-43-0-35-45-41,25497-29-23-24,0]
            [JA3: 50725b8359a5837675140c4d18ff7fb1]

한 줄 한 줄 무엇을 의미 하는지 알아보자


-> Transport Layer Security

TLS 를 의미


Transport Layer Security
->  TLSv1.3 Record Layer: Handshake Protocol: Client Hello

TLSv1.3

Client 에서 원하는 TLS 버전을 의미

Record Layer

  • 다양한 유형의 데이터를 캡슐화 하여 전송하는 단위
  • 모든 TLS 메시지의 기반이 되는 구조

Handshake Protocol

  • 핸드셰이크를 진행하기 위한 프로토콜을 나타냄

Client Hello

  • [[TLS 1.3 Handshake]] 에서 확인 가능 한 요청 흐름

Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
->      Content Type: Handshake (22)

Content Type

여기서 올 수 있는 값은 아래와 같음

  • Change Cipher Spec (20) : 0x14
  • Alert (21) : 0x15
  • Handshake (22) : 0x16 이 옵션은 아래의 메시지를 포함함
    • ClientHello (1)
    • ServerHello
    • Certificate
    • Finished
  • Application Data (23) : 0x17

Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
->      Version: TLS 1.0 (0x0301)

Version

이건 현재 사용하고 있는 TLS 의 버전을 의미하는 것은 아니다

왜 헷깔리게 version 이라고 함?

하위 호환성

기존의 TLS 1.1 / TLS 1.2 는 이 필드를 사용했다. 다운그레이드 방지 목적으로 사용했다고 하는데, 현재는 RFC-8446 에 의해 0x0303 으로 설정 하라고 명시 되어 있다 (위 패킷 분석에서 나오는 0x0301 은 TLS 1.0 을 의미 하는 것으로, 브라우저에서 지원하는 최저 다운그레이드 버전을 의미 하는듯)


Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
        Version: TLS 1.0 (0x0301)
->      Length: 2050

Length

  • TLS 레코드에 포함 된 실제 데이터(Payloa) 의 길이를 바이트 단위로 나타낸 것

Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
        Version: TLS 1.0 (0x0301)
        Length: 2050
->      Handshake Protocol: Client Hello
->          Handshake Type: Client Hello (1)

Handshake Type

여러 가지 핸드셰이크 메시지 유형을 정의 하며 이 필드는 현재 메시지의 유형을 나타낸다

Client Hello (1)

핸드셰이크 메시지의 현재 타입을 타나내는 것 이외에 올 수 있는 메시지는 아래와 같다

  • Client Hello (1)
    • 클라이언트가 보내는 첫 번째 메시지
    • 클라이언트 암호화 옵션, TLS 버전, 난수 값 등이 포함됨
  • Server Hello (2)
    • Client Hello 에 응답하는 메시지
    • 선택 된 Cipher suite, 서버의 난수 값 등이 포함된
  • Hello Verify Request (3)
    • DTLS(Datagram Transport Layer Security)에서 사용됨
    • 클라이언트의 IP 주소가 위조 되지 않았는지 확인하기 위해 서버가 보내는 메시지
  • New Session Ticket (4)
    • 서버가 클라이언트에게 새로운 세션 티켓을 발급하는 메시지로, 세션 재개를 지원
  • End of Early Data (5)
    • TLS 1.3에서 사용되며, 클라이언트가 0-RTT 데이터 전송을 종료할 때 보내는 메시지
  • Encrypted Extensions (8)
    • TLS 1.3에서 서버가 클라이언트에 추가 확장 정보를 암호화된 상태로 보내는 메시지
  • Certificate (11)
    • 서버 또는 클라이언트가 자신의 인증서를 상대방에게 제공하는 메시지로, 신뢰성을 증명하기 위해 사용
  • Server Key Exchange (12)
    • 핸드셰이크 과정에서 서버가 키 교환을 위해 추가적인 데이터를 클라이언트에게 보내는 메시지 (TLS 1.3에서는 사용되지 않음)
  • Certificate Request (13)
    • 서버가 클라이언트에게 인증서를 요청하는 메시지로, 주로 양방향 인증에서 사용
  • Server Hello Done (14)
    • 서버가 클라이언트에게 모든 핸드셰이크 메시지를 보냈음을 알리는 메시지 (TLS 1.3에서는 사용되지 않음)
  • Certificate Verify (15)
    • 클라이언트 또는 서버가 자신의 인증서에 대한 유효성을 증명하기 위해 서명된 데이터를 보내는 메시지
  • Client Key Exchange (16)
    • 클라이언트가 세션 키 생성을 위해 필요한 데이터를 서버에게 보내는 메시지 (TLS 1.3에서는 사용되지 않음)
  • Finished (20)
    • 핸드셰이크가 완료되었음을 알리는 메시지
    • 이후의 모든 통신이 이 메시지 이후부터 암호화
  • Key Update (24)
    • TLS 1.3에서 키 자료를 업데이트하기 위해 사용되는 메시지
  • Message Hash (254)
    • TLS 1.3에서 핸드셰이크 메시지의 해시를 포함하는 메시지로, 일부 확장 사용 시에 활용

Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
        Version: TLS 1.0 (0x0301)
        Length: 2050
        Handshake Protocol: Client Hello
            Handshake Type: Client Hello (1)
->          Length: 2046

Length

TLSv1.3 Record Layer: Handshake Protocol: Client Hello > Length 는 해당 TLS 메시지 전문에 대한 데이터(Payload) 길이 이지만, 여기서의 Length 는 Client Hello 에 대한 데이터(Payload) 길이 이다


Transport Layer Security
    TLSv1.3 Record Layer: Handshake Protocol: Client Hello
        Content Type: Handshake (22)
        Version: TLS 1.0 (0x0301)
        Length: 2050
        Handshake Protocol: Client Hello
            Handshake Type: Client Hello (1)
            Length: 2046
->          Version: TLS 1.2 (0x0303)


참조

   -  Updating the "pre_shared_key" extension if present by recomputing
      the "obfuscated_ticket_age" and binder values and (optionally)
      removing any PSKs which are incompatible with the server's
      indicated cipher suite.

   -  Optionally adding, removing, or changing the length of the
      "padding" extension [[RFC7685](<https://www.rfc-editor.org/rfc/rfc7685> ""A Transport Layer Security (TLS) ClientHello Padding Extension"")].

   -  Other modifications that may be allowed by an extension defined in
      the future and present in the HelloRetryRequest.

   Because TLS 1.3 forbids renegotiation, if a server has negotiated
   TLS 1.3 and receives a ClientHello at any other time, it MUST
   terminate the connection with an "unexpected_message" alert.

   If a server established a TLS connection with a previous version of
   TLS and receives a TLS 1.3 ClientHello in a renegotiation, it MUST
   retain the previous protocol version.  In particular, it MUST NOT
   negotiate TLS 1.3.

   Structure of this message:

      uint16 ProtocolVersion;
      opaque Random[32];

      uint8 CipherSuite[2];    /* Cryptographic suite selector */

      struct {
          ProtocolVersion legacy_version = 0x0303;    /* TLS v1.2 */
          Random random;
          opaque legacy_session_id<0..32>;
          CipherSuite cipher_suites<2..2^16-2>;
          opaque legacy_compression_methods<1..2^8-1>;
          Extension extensions<8..2^16-1>;
      } ClientHello;