Monday, 10 October 2016

VPN Interview Questions and answes


What is VPN?

Virtual private network provide secure communication over unsecured network (internet).

It secures communication by using:

1.   Authentication 

2.   Confidentiality

3.   Data Integrity 

4.   Anti-replay



Types of VPN:




1.      Remote Access VPN:

It allow user to connect to a private network and access its services and resources remotely. The connection between the user and the private network happens through the Internet and the connection is secure and private. It is supported by SSL and IPSEC.



2.      Site to Site VPN:

It allow to established secure connection between two sites over unsecured medium. IPSEC is commonly used for S2S VPN.



Types of VPN protocol:

     PPTP

     L2TP

     IPSEC

     SSL

     MPLS VPN



What is Authentication, Confidentiality & Integrity?



Authentication - Verifies that the packet received is actually from the claimed sender. It verifies the authenticity of sender. Pre-shared Key, Digital Certificate is some methods that can be used for authentication.

Integrity - It make sure that packet do not get temper or modify in transit. Hashing Algorithm includes MD5, SHA.



Confidentiality - it provide encryption so that data is not disclosed to unauthorized parties, only authorized party can decrypt it. Encryption algorithms include DES (Data Encryption Standard), 3DES (Triple-DES), AES (Advanced Encryption Standard).



What is Symmetric and Asymmetric Encryption?



In symmetric encryption, a single key is used both to encrypt and decrypt traffic. It is also referred as shared key or shared secret encryption. Symmetric encryption algorithms include DES, 3DES, AES.

In Asymmetric encryption two keys are used to encrypt and decrypt traffic, one for encryption and one for decryption. The most common asymmetric encryption algorithm is RSA.



What is IPSEC?



IPSEC is suite of protocol that provide Authentication, Confidentiality, Data integrity and anti replay. IPSEC has two modes:

Transport mode

Tunnel mode

IPSEC support ESP and AH protocol.



What is IKE/ISAKMP?



ISAKMP defines the procedures for authenticating a communicating peer, creation and management of Security Associations, key generation techniques and threat mitigation (e.g. denial of service and replay attacks).

ISAKMP use UDP port 500 and 4500 for communication.



IKE has two phases:



Phase-I: it is use to authenticate the peer, generate the shared secret key and build phase-1 tunnel. 

It also protects the negotiation of phase 2 communication. At the end of phase 1, a bidirectional SA (phase 1 SA) is established for IKE communication.

There are two modes in IKE phase 1:-

Main mode - Total Six messages are exchanged in main mode for establishing phase 1 SA.

Aggressive mode - It is faster than the main mode as only three messages are exchanged in this mode to establish phase 1 SA. It is faster but less secure since identity revel in very first packet.



Phase-II: it is where actual data get encrypt and decrypt.

Phase-II negotiate it all parameter under phase I tunnel. At the end of phase II unidirectional SA formed for inbound and outbound communications.



Phase-II has one mode which is quick mode.

Quick mode - In this mode three messages are exchanged to establish the phase 2 IPSec SA.



At what layer IPsec works?

 Layer 3 of the OSI model.



Explain phase-I and Phase-II message exchange?



Phase I Main Mode:





IKE Phase 1 operating in main mode works with both parties exchanging a total of 6 packets.

1.   The first packet is sent from the initiator of the IPSec tunnel to its remote endpoint, this packet contains the ISAKMP policy

2.   The second packet is sent from the remote endpoint back to the initiator, this packet will be the exact same information matching the ISAKMP policy sent by the initiator.

3.   The third packet is sent from the initiator to the remote endpoint, this packet contains the Key Exchange payload and the Nonce payload, the purpose of this packet is generate the information for the DH secret key

4.   This fourth packet as you would expect comes from the remote endpoint back to initiator and contains the remote endpoints Key Exchange and Nonce payload.

5.   The fifth packet is from the initiator back to the remote endpoint with identity and hash payloads, the identity payload has the device’s IP Address in, and the hash payload is a combination of keys (including a PSK, if PSK authentication is used)

6.   The sixth packet from the remote endpoint to the initiator contains the corresponding hash payloads to verify the exchange.

 



Phase 2 - Quick Mode



All messages in Quick mode are encrypted.

  • Perfect Forward Secrecy PFS, if PFS is configured on both endpoints the will generate a new DH key for phase 2/quick mode.

1.   Contained in this first packet from the initiator to the remote device are some of the hashes/keys negotiated from phase 1, along with some IPSec parameters IE: Encapsulation (ESP or AH), HMAC, DH-group, and the mode (tunnel or transport)

2.   The second packet contains the remote endpoint’s response with matching IPSec parameters.

3.   The last packet is sent to the remote device to verify the other device is still there and is an active peer.

 





What is Diffie-Hellman?



DH is a public-key cryptography protocol which allows two parties to establish a shared secret over an insecure communications channel. Diffie-Hellman is used within IKE to establish session keys and is a component of Oakley.



How Diffie-Hellman works?



Each side have a private key which is never passed and a Diffie-Hellman Key (Public Key used for encryption). When both side wants to do a key exchange they send their Public Key to each other. for example Side A get the Public Key of Side B, then using the RSA it creates a shared key which can only be opened on Side B with Side B's Private Key So, even if somebody intercepts the shared key he will not be able to do reverse engineering to see it as only the private key of Side B will be able to open it.



What is the difference between Transport and Tunnel mode?



Tunnel mode - Protects data in network-to-network or site-to-site scenarios. It encapsulates and protects the entire IP packet and add new IP header.



Transport mode - Protects data in host-to-host communications. In transport mode, IPSec protects the payload of the original IP datagram by excluding the IP header.

IPSec protocols AH and ESP can operate in either transport mode or tunnel mode.



Explain IPsec Protocol?



Encapsulating Security Payload (ESP) - It is an IP-based protocol which uses port 50 for communication between IPsec peers. ESP is used to protect the confidentiality, integrity and authenticity of the data and offers anti-replay protection.

Drawback - ESP does not provide protection to the outer IP Header



Authentication Header (AH) - It is also an IP-based protocol that uses port 51 for communication between IPsec peers. AH is used to protect the integrity and authenticity of the data and offers anti-replay protection.

Unlike ESP, AH provides protection to the IP header also.

Drawback - AH does not provide confidentiality protection and it can not be use when VPN is behind the NAT device since it provide authentication for whole header(including IP).



What is anti-replay protection?

Both ESP and AH protocols provide an anti-reply protection based on sequence numbers. The sender increments the sequence number after each transmission and the receiver checks the sequence number and reject the packet if it is out of sequence.





Why can't an ESP packet pass through a PAT device?

It is precisely because ESP is a protocol without ports that prevents it from passing through PAT devices.  Because there is no port to change in the ESP packet, the binding database can't assign a unique port to the packet at the time it changes its RFC 1918 address to the publically routable address.  If the packet can't be assigned a unique port then the database binding won't complete and there is no way to tell which inside host sourced this packet.  As a result there is no way for the return traffic to be untranslated successfully.





How does NAT-T work with ISAKMP/IPSec?



NAT Traversal performs two tasks: 

1.      Detects if both ends support NAT-T 

2.      Detects NAT devices along the transmission path (NAT-Discovery)



Step one occurs in ISAKMP Main Mode messages one and two.  If both devices support NAT-T, then NAT-Discovery is performed in ISKAMP Main Mode messages (packets) three and four.  The NAT-D payload sent is a hash of the original IP address and port. Devices exchange two NAT-D packets, one with source IP and port, and another with destination IP and port. The receiving device recalculates the hash and compares it with the hash it received; if they don't match a NAT device exists. 



 If a NAT device has been determined to exist, NAT-T will change the ISAKMP transport with ISAKMP Main Mode messages five and six, at which point all ISAKMP packets change from UDP port 500 to UDP port 4500.  



NAT-T encapsulates the Quick Mode (IPsec Phase 2) exchange inside UDP 4500 as well.  After Quick Mode completes data that gets encrypted on the IPsec Security Association is encapsulated inside UDP port 4500 as well, thus providing a port to be used in the PAT device for translation. 

When a packet with source and destination port of 4500 is sent through a PAT device (from inside to outside), the PAT device will change the source port from 4500 to a random high port, while keeping the destination port of 4500. When a different NAT-T session passes through the PAT device, it will change the source port from 4500 to a different random high port, and so on. This way each local host has a unique database entry in the PAT devices mapping its RFC1918 ip address/port4500 to the public ip address/high-port.



What is the difference between NAT-T and IPSec-over UDP? 



When NAT-T is enabled, it encapsulates the ESP packet with UDP only when it encounters a NAT device. Otherwise, no UDP encapsulation is done. But, IPSec Over UDP, always encapsulates the packet with UDP.



NAT-T always use the standard port, UDP-4500. It is not configurable. IPSec over UDP normally uses UDP-10000 but this could be any other port based on the configuration on the VPN server.





What is GRE?

Generic Routing Encapsulation Protocol is a tunneling protocol developed by Cisco designed to encapsulate IP unicast, multicast and broadcast packets. It uses IP protocol number 47.



Which protocol and ports are need to allowed when IPEC VPN traffic passing through firewall which is placed between VPN peer?



Protocol: ESP,AH

Port: UDP 500/4500



Differences between IKEv1and IKEv2?



1.   IKEV1 need to exchange 9 packets to build IPSEC SA whereas IKEv2 required only 4 packets exchange.

2.   There is no mode(main mode, aggressive mode)  in IKEv2

3.   In built NAT-T,dead peer detection  in IKEV2.

4.   DOS protection IN IKEv2

5.   EAP auth supported in IKEv2

6.   In IKEv2 Informational messages have to be acknowledged. This should address some synchronization issues we saw with IKEv1

7.   Asymmetric authentication supported in ikev2 . E.G.        we can authenticate our self with pre-shared-key and authenticate peer with certificates.



What is SA?



SA is an agreement or a contract between two IPSec peers or endpoints. The SA contains all the information required for the two peers to exchange data securely.



What is route based VPN and policy based VPN?

A route based VPN creates a virtual IPSec interface (tunnel interface), and whatever traffic hits that interface is encrypted and decrypted according to the phase 1 and phase 2 IPSec settings.

In policy based VPN the tunnel is specified within the policy itself with an action of "IPSec".

A route based VPN only works in route mode, where policy based VPN works in both route and transparent mode.



What is split tunneling and full tunneling?



Split tunneling encrypts only traffic which is allowed through VPN and rest of traffic will send unencrypted.

Full tunnel encrypts all traffic, in that case you will not able to access your local resources.



What is RRI?



Reverse route injection (RRI) is the ability for static routes to be automatically inserted into the routing process for those networks and hosts that are protected by a remote tunnel endpoint.

Each route is created on the basis of the remote proxy network and mask, with the next hop to this network being the remote tunnel endpoint



What is SSL VPN?
It provides remote access connectivity from internet enabled device through a standard web browser. It does not require any special client software at a remote site.

It uses TCP port 443 and work between application layer and transport layer.

Types of SSL VPN:


1.Clientless mode –

Clientless mode provides secure access to web resources and web-based applications. It does not provide access to TCP connections such as SSH or Telnet.

2. Thin client mode –

Thin client mode provides remote access to TCP-based services such as Telnet, SSH, SMTP etc. applications. Thin client is delivered via a Java applet that is dynamically downloaded from the SSL VPN appliance upon session establishment.

3. Thick client mode –

It works at Layer 3 and is also known as tunnel mode or full tunneling client. It is like IPSEC remote access where we can access allowed network ranges.

Explain SSL Handshake?
1.Client initiates by sending a CLIENT HELLO message which contains SSL version that the client supports, in what order the client prefer the versions, Ciphersuits (Cryptographic Algorithms) supported by the client, Random Number.
2.Server will send back a SERVER HELLO message Which contains Version Number (Server selects SSL version that is supported by both the server and the client), Cipher Suits (selected by server the best cipher suite version that is supported by both of them), Session ID, Random Data.
3.Server also sends PKI certificate for authenticating himself signed and verified by Certificate Authority along with the public key for encryption.
4.Server will than send Server Hello Done indicating that the server has finished sending its hello message, and is waiting for a response from the client.
5.Client will sends its certificate if the server has also requested for client authentication in server hello message.
6.Client will sends Client Key Exchange message after calculating the premaster secret with the help of the random values of both the server and the client. This message is sent by encrypting it with the server's public key which was shared through the hello message.
Server will decrypt the premaster secret with its private key. Now both client and server will perform series of steps to generate session keys (symmetric) which will be used for encryption and decryption of data exchanges during SSL session and also to verify its integrity.
7. Client will send CHANGE CIPHER SUITE message informing the server that future messages will be encrypted using session key.
8. Client will send CLIENT FINISH (DONE) message indicating that client is done.
9. Server will also send CHANGE CIPHER SUITE message.
10.Server  will also send SERVER FINISH (DONE) message



Firewall interview questions

What is a firewall?
Firewall is a device which is used to filter the traffic moving from one zone to another zone.
Basically it is placed between a trusted and an untrusted network. It deny or permit traffic that enters or leaves network based on pre-configured policies. Firewalls protect inside networks from unauthorized access by untrusted network.

What is packet flow of ASA, checkpoint and SRX?
ASA:

1. The packet is reached at the ingress interface.
2. Once the packet reaches the internal buffer of the interface, the input counter of the interface is incremented by one.
3. Cisco ASA first looks at its internal connection table details in order to verify if this is a current connection. If the packet flow matches a current connection, then the Access Control List check is bypassed and the packet is moved forward.If packet flow does not match a current connection, then the TCP state is verified. If it is a SYN packet or UDP (User Datagram Protocol) packet, then the connection counter is incremented by one and the packet is sent for an ACL check. If it is not a SYN packet, the packet is dropped and the event is logged.
4. The packet is processed as per the interface ACLs. It is verified in sequential order of the ACL entries and if it matches any of the ACL entries, it moves forward. Otherwise, the packet is dropped and the information is logged. The ACL hit count is incremented by one when the packet matches the ACL entry.
5. The packet is verified for the translation rules. If a packet passes through this check, then a connection entry is created for this flow and the packet moves forward. Otherwise, the packet is dropped and the information is logged.
6. The packet is subjected to an Inspection Check.If it passed the inspection, it is moved forward. Otherwise, the packet is dropped and the information is logged.Additional security checks will be implemented if a Content Security (CSC) module is involved.
7. The IP header information is translated as per the Network Address Translation/ Port Address Translation (NAT/PAT) rule and checksums are updated accordingly. The packet is forwarded to Advanced Inspection and Prevention Security Services Module (AIP-SSM) for IPS related security checks when the AIP module is involved.
8. The packet is forwarded to the egress interface based on the translation rules. If no egress interface is specified in the translation rule, then the destination interface is decided based on the global route lookup.
9. On the egress interface, the interface route lookup is performed. Remember, the egress interface is determined by the translation rule that takes the priority.
10. Once a Layer 3 route has been found and the next hop identified, Layer 2 resolution is performed. The Layer 2 rewrite of the MAC header happens at this stage.
11. The packet is transmitted on the wire, and interface counters increment on the egress interface.
Checkpoint Firewall packet Flow:
1. SAM rule database
2. Anti-spoofing
3. Session lookup
4. Policy lookup
5. Destination NAT
6. Routing
7. Source NAT

SRX(Juniper) Packet flow:
When traffic reach to interface, it check session table to identify the connection is already established or not.If connection is not a new connection then it will go through fast path otherwise go through first path.
Here are the steps for first path flow processing:
a) Screen check
b) Destination NAT/ static DST NAT
C) Route lookup
d) destination zone lookup
e) Firewall policy lookup
f) NAT policy lookup
g) ALG
h) IDP, VPN other services
i) session installation

Here are the steps for fast path flow processing:
a) Screen check
b) TCP header and flag check
c)route lookup/ NAT
d)ALG processing
e) IDP and VPN services

Firewalls works at which Layers?
Firewalls work at layer 2, 3, 4 & 7

What is the difference between Stateful & Stateless Firewall?

Stateful firewall - A Stateful firewall is track the connections that pass through it and allow return traffic by lookup connection table. It adds and maintains information about connections in state table, referred to as a connection table.
Stateful firewall maintains following information in its State table:-
1.Source IP address.
2.Destination IP address.
3.source port
4 Destination port
5 protocol
TCP Sequence Numbers, and TCP Flags.

Stateless firewall- (Packet Filtering) Stateless firewalls on the other hand, does not look at the state of connections but just at the packets themselves.

Explain NAT with respect to ASA?

NAT( Network address translation)  is mechanism of translating IP address or network with different IP or with the same address.

Types of NAT:

Static NAT: one to one mapping between real address and map address. It is bi-directional.

Dynamic NAT: A group of real IPs are translated with group of mapped IP address. It is unidirectional.

PAT: A group of real IP address mapped with single IP address using unique source port. Source port is used to build translation table.

Policy NAT: It allow us to do the translation when connection is from specific source and destination.

Identity NAT: It use to translate real IP address or network to itself. Basically it is use when we want to bypass
NAT.

Explain Types of NAT in Checkpoint firewall?

Static NAT - One to one translation
Hide/Dynamic NAT - Allows us to NAT multiple IPs behind one IP/Interface
Automatic NAT - basic address NAT translation, which can be configured within object and we can define only  source for translation.
Manual NAT - Allows greater flexibility over automatic NAT, here we can do define source and destination as well.
Server Side NAT - destination is NAT`d by the outbound kernel.
Client Side NAT  - destination is NAT`d by the inbound kernel.










Network security Interview questions & answers

TCP:
1. Explain 3 way handshake process?
A three-way-handshake is a method used in a TCP/IP network to create a virtual connection between a client and server before transferring data. It is a three-step method that requires both the client and server to exchange SYN and ACK (acknowledgment) packets before actual data communication begins.

 

2. What is the importance of sequence number?

It is 32 bit field in TCP header which is used track the data sent and received.
TCP keeps track of data by assigning a sequence number to each byte sent, then it uses the corresponding acknowledgement numbers to determine if any data was lost in transit. At the beginning of a TCP connection, each side will start by using an Initial Sequence Number (ISN) which between 0 to 4,294,967,295(2^32).



3. What is the difference between Total length and header length?
Total length is header length + data
Header length is size of header.

4. What does window size indicate?

Window size indicate amount of data can received by host without sending acknowledgement.
TCP window is for efficient data transfer and flow control.

 

5. What is MSS and When the MSS value is getting negotiated?

MSS is part of TCP option field, it is used to define the maximum segment that will be used during a connection between two hosts. 
It is negotiated during the initial SYN and SYN/ACK phase of the TCP 3-way-handshake.
 
 

6. What is the difference between PUSH and URG flag?
PSH is used to ask receiving host not to buffer packets, but to process them as soon as they are received whereas URG flag is used to indicate that the packet should be given priority over other packets for processing.

7. What is the purpose of RST bit?

It indicate that service is not listening on given port.

8. What is SACK?

It is part of TCP option field called  as selective ack.
Receiver host send SACK to sender indicating that this amount of data has been received, you have to retransmit only missing data instead of retransmitting complete data.

 

9. Difference between TCP and UDP

10. TCP, UDP Header
TCP Header:















UDP Header:










11. What is Urgent Pointer In TCP field?

The URG pointer tell how many bytes of the data is urgent in the segment that has arrived. Let us assume  if the data size is 500 bytes and only first 100 bytes is urgent, the urgent pointer will have a value of 50.
When urgent flag is set to 1, urgent pointer also set.



IP:

1. Which ICMP message confirms the trace route is completed?
      Destination unreachable
2. What is Fragmentation ?
 Dividing IP packets into smaller pieces (fragments). Fragmentation is required when the packet is       larger than the MTU. Each fragment than becomes a datagram in itself and transmitted independently from source. These datagrams are reassembled only by the destination.

3. What is the importance of identification field in the IP packet?

It is 16bit field in IP header which is used to identify fragmented packets at receiver end.
E.g : Lets assume  packet length is 1600 bytes which need to be fragment(DF=0); so 1600 bytes data is further fragmented in 1500bytes and 100 bytes and both fragmented packet will have same ID value in identification field so that receiver can identify that both fragmented packets belong from same packet.

4. What is the importance of DF, MF flag?

IP header has flag field which has 3bit:
Reserved
DF
MF
Don’t fragment bit:
If DF bit is equal to 1, fragmentation is not allowed.
If DF bit set to 0, it means fragmentation is allowed.

when a router needs to forward a packet larger than the outgoing interface’s MTU, the router either fragments the packet or discards it. If the IP header’s Do Not Fragment (DF) bit set, the router discards the packet. If the DF bit is not set, fragmentation will be done by router.

More fragments bit:
If MF Bit is set to 1 means more fragments packet are coming. If it is set to 0 means This is the Last Fragment.
All fragments that belong to an IP datagram will have more fragments bit set except for the last packet. Last fragmented packet must have MF=0.
















5: What is the purpose of fragment offset?
It is used to define the Size of each Fragmented Packet and useful for rearrange the fragmented packet in correct order.
6. What does the protocol field determines in the IP packet?

    It has 8-bit field in IP header which is used to define which protocol is running on above layer.