Method and device for realizing firewall function of operating system based on eBPF technology

By using eBPF technology at the data link layer to process network data packets, the operating system firewall can effectively identify and intercept network attacks, solving the problem that traditional firewalls cannot analyze the content of data packets, improving network security control capabilities, and reducing management complexity. performance and maintenance costs.

CN118694561AInactive Publication Date: 2024-09-24SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410602294.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-15
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional operating system firewalls cannot analyze the content of data packets and cannot intercept application layer attacks, resulting in low network security control capabilities, complex management, low efficiency, high maintenance costs, high hardware firewall prices, and the inability to meet the needs of diverse attacks on modern networks.

Method used

Using the operating system firewall method based on eBPF technology, by mounting the eBPF hook function that processes ingress data at the data link layer, parsing and processing data packets, the internal and external firewall function is realized, and network traffic is judged and processed according to configured business rules. Including parameters such as whitelist, blacklist, request keywords and response keywords.

Benefits of technology

It improves the efficiency and processing speed of the firewall function, can effectively identify and intercept network attacks, reduce illegal access, achieve internal and external protection, reduce the probability of network attacks, and reduce the management complexity and maintenance costs caused by device overlay.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118694561A
    Figure CN118694561A
Patent Text Reader

Abstract

The invention discloses a method and a device for realizing a firewall function of an operating system based on an eBPF technology, and relates to the technical field of firewalls. Aiming at the function deficiency of a traditional operating system firewall and the defects existing in an equipment superposition scheme adopted by the existing network security, the method comprises the following steps of: (1) preparation work: configuring firewall parameters, and translating the configuration parameters into an automatic drilling task file; and (2) on the basis of an eBPF technology working on a data link layer, performing protection work: 1) mounting an eBPF hook function for processing entry data at a network entry point, 2) analyzing an obtained data packet and extracting contents in the data packet, 3) calling service processing logic to realize internal and external firewall functions, and 4) finishing data packet processing. According to the invention, the firewall function of the operating system can be quickly and efficiently completed based on business logic analysis, and both external and internal protection can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of firewall technology, and in particular to a method and device for realizing an operating system firewall function based on eBPF technology. Background Art

[0002] With the rapid development of network applications, the network structure has become very complex, and the limitations of traditional firewalls have been clearly reflected: traditional operating system firewalls are based on packet filtering functions and work at the network layer. Taking Linux as an example, IPTABLES works in user mode and is a command for managing firewalls. NETFILTER implements packet filtering firewall functions in kernel mode. The working mode of packet filtering functions is based on access control lists (ACLs) to implement firewall functions. It determines which data packets are allowed to pass by checking the source address, destination address, all ports and protocol status of each data packet in the data stream, or their combination; its working principle determines that it cannot analyze the content of the data packet and cannot intercept attacks from the application layer, such as worms, viruses and Trojans. Traditional operating system firewalls cannot distinguish the specific applications and their contents in the traffic, cannot distinguish users, and cannot analyze and record user behavior, so they cannot refine the network traffic attributes, so they have low control over the network and cannot provide good service quality; its inability to analyze and record user behavior will not meet security requirements.

[0003] Due to the lack of firewall functions in traditional operating systems, enterprises need to adopt a device stacking solution to target the existing diverse attack types when building network security, resulting in a "candied haws" type of deployment. The network security solutions we see are implemented in the form of firewalls, intrusion prevention systems, gateway antivirus, and other equipment stacking. This approach can make up for the defects of the single function of traditional firewalls in some aspects, and form a seemingly comprehensive protection against various attacks in the network. However, in this environment, managers usually encounter the following difficulties:

[0004] (1) Low efficiency: The same data packet will be repeatedly unpacked and parsed after passing through various devices connected in series, which will make the efficiency of the entire network low and the network speed very slow;

[0005] (2) High maintenance cost: A large number of equipment requires sufficient space and environmental support, which greatly increases maintenance costs;

[0006] (3) Complex management: The equipment is interconnected and management is complex, requiring the training of senior management personnel who are familiar with various types of equipment and equipment from various manufacturers; it is impossible to conduct a unified security risk analysis.

[0007] (4) Impact on performance: If it is not a separate hardware firewall, it is fine when the data traffic is small. However, when the network traffic is large to a certain extent, it will have a relatively large impact on system performance.

[0008] (5) High price of hardware firewall: The price of a single hardware firewall is very high.

[0009] eBPF is a top-level submodule in the Linux kernel. It is developed from BPF and is the most advanced packet filtering technology. It works at the data link layer and has a very high filtering efficiency. It plays an important role in system tracking, observation, performance tuning, security, and networking. The eBPF program architecture emphasizes security and stability. It looks more like a kernel module, but unlike a kernel module, the eBPF program does not require the kernel to be recompiled, and it can ensure that the eBPF program runs to completion without causing a system crash.

[0010] The performance of eBPF technology in network technology is even more eye-catching. The combination of BPF technology with XDP (eXpress DataPath) and TC (Traffic Control) can realize more powerful network functions and provide basic support for SDN software-defined networks. XDP only acts on the Ingress level of network packets. The BPF hook is located as early as possible in the network driver, and the best packet processing performance can be achieved without copying the original packet. The mounted BPF program is an ideal choice for running filtering, which can be used to discard malicious or unexpected traffic and perform DDOS attack protection. TCIngress is at a higher level than XDP technology. The BPF program runs before the L3 layer and can access most of the metadata related to the data packet. It is an ideal place for local node processing and can be used for traffic monitoring or L3 / L4 endpoint policy control. At the same time, with TC egress, a higher-dimensional and higher-level network structure can be achieved in the container environment.

[0011] Based on this, a method and device for realizing the firewall function of an operating system based on eBPF technology are provided, which improves system stability and reliability while ensuring filtering efficiency and reduces the probability of network attacks. Summary of the invention

[0012] In view of the needs and deficiencies of current technological development, the present invention provides a method and device for realizing an operating system firewall function based on eBPF technology.

[0013] In the first aspect, the present invention provides a method and device for implementing an operating system firewall function based on eBPF technology. The technical solution adopted to solve the above technical problems is as follows:

[0014] A method for implementing an operating system firewall function based on eBPF technology comprises the following steps:

[0015] 1. Preparation

[0016] Configure firewall parameters;

[0017] Translate configuration parameters into task files for automated drills;

[0018] (II) Protection based on eBPF technology working at the data link layer

[0019] 1) Mount the eBPF hook function that processes the entry data at the network entry point;

[0020] 2) Parse the acquired data packets and extract the contents of the data packets;

[0021] 3) Call business processing logic to implement internal and external firewall functions;

[0022] 4) Packet processing is completed.

[0023] Optionally, the configured firewall parameters include: open ports, whitelist, blacklist, request keyword, response keyword, blacklist removal time, blacklist entry frequency, and whitelist exit frequency.

[0024] Optionally, the configuration parameters are translated into task files for automated drills, as follows:

[0025] Open ports, configure external access to local ports. If it is not an open port, access is prohibited;

[0026] Whitelist, configure trusted IP addresses or IP addresses and ports;

[0027] Blacklist, configure untrusted IP addresses, and do not accept any network requests after configuration;

[0028] The request keyword and the response keyword are keywords contained in the business data part of the network packet, using a segment of characters starting from the head, tail, or a specified position in the middle.

[0029] Further optionally, step 2) is performed to extract the content in the data packet, including the protocol type, IP, port, and data packet content.

[0030] Optionally, step 3) is performed, and the specific implementation process of the business processing logic is as follows:

[0031] a) Read configuration parameters, including whitelist, blacklist, request frequency and time limit for adding common IP to blacklist, request frequency and time limit for adding whitelist to blacklist, and time for removal from blacklist;

[0032] b) Check the data packet port, that is, the port configured in the configuration file. If the port is not an open port, directly add the requested IP to the blacklist and discard the requested data packet. If the port is an open port, continue to step c);

[0033] c) Check whether the IP address of the data packet is in the whitelist. If yes, proceed to step d), otherwise jump to step f);

[0034] d) Analyze whether the data packet is the service configured in the configuration file, if yes, continue to step e), otherwise discard the packet and add it to the blacklist;

[0035] e) Determine whether the request in the whitelist exceeds the request frequency. If yes, discard the current data and add it to the blacklist to prevent illegal access from normal IP addresses. Otherwise, release it. If it is not in the whitelist, add it to the whitelist and the process ends;

[0036] f) Determine whether it is on the blacklist, if yes, proceed to step g), otherwise jump to step e);

[0037] g) Determine whether there is no request within the configured time period. If yes, release the request, remove it from the blacklist, and jump to step d). Otherwise, continue to step h);

[0038] h) Determine whether there is a request within the configured time period. If yes, release it, remove it from the blacklist, and jump to step d). Otherwise, update the request time of the blacklist, discard the data packet, and the process ends.

[0039] In a second aspect, the present invention provides a method and device for implementing an operating system firewall function based on eBPF technology. The technical solution adopted to solve the above technical problems is as follows:

[0040] A device for implementing an operating system firewall function based on eBPF technology, comprising:

[0041] Configuration module, used to configure firewall parameters;

[0042] Parameter translation module, used to translate configuration parameters into task files for automated drills;

[0043] The protection processing module is used to mount the eBPF hook function for processing entry data at the network entry point, parse the obtained data packets and extract the content in the data packets, call the business processing logic, implement the internal and external firewall functions, and complete the data packet processing.

[0044] Optionally, the firewall parameters configured by the configuration module involved include: open ports, whitelist, blacklist, request keyword, response keyword, blacklist removal time, blacklist entry frequency and whitelist exit frequency.

[0045] Further optionally, the parameter translation module involved translates the configuration parameters into a task file for the automated drill, as follows:

[0046] Open ports, configure external access to local ports. If it is not an open port, access is prohibited;

[0047] Whitelist, configure trusted IP addresses or IP addresses and ports;

[0048] Blacklist, configure untrusted IP addresses, and do not accept any network requests after configuration;

[0049] The request keyword and the response keyword are keywords contained in the business data part of the network packet, using a segment of characters starting from the head, tail, or a specified position in the middle.

[0050] Further optionally, the protection processing module involved parses the acquired data packet and extracts the content in the data packet, including the protocol type, IP, port, and data packet content.

[0051] Further optionally, the protection processing module involved calls the business processing logic, and the specific implementation process of the business processing logic is as follows:

[0052] a) Read configuration parameters, including whitelist, blacklist, request frequency and time limit for adding common IP to blacklist, request frequency and time limit for adding whitelist to blacklist, and time for removal from blacklist;

[0053] b) Check the data packet port, that is, the port configured in the configuration file. If the port is not an open port, directly add the requested IP to the blacklist and discard the requested data packet. If the port is an open port, continue to step c);

[0054] c) Check whether the IP address of the data packet is in the whitelist. If yes, proceed to step d), otherwise jump to step f);

[0055] d) Analyze whether the data packet is the service configured in the configuration file, if yes, continue to step e), otherwise discard the packet and add it to the blacklist;

[0056] e) Determine whether the request in the whitelist exceeds the request frequency. If yes, discard the current data and add it to the blacklist to prevent illegal access from normal IP addresses. Otherwise, release it. If it is not in the whitelist, add it to the whitelist and the process ends;

[0057] f) Determine whether it is on the blacklist, if yes, proceed to step g), otherwise jump to step e);

[0058] g) Determine whether there is no request within the configured time period. If yes, release the request, remove it from the blacklist, and jump to step d). Otherwise, continue to step h);

[0059] h) Determine whether there is a request within the configured time period. If yes, release it, remove it from the blacklist, and jump to step d). Otherwise, update the request time of the blacklist, discard the data packet, and the process ends.

[0060] The method and device of the present invention for realizing the firewall function of an operating system based on the eBPF technology have the following beneficial effects compared with the prior art:

[0061] The present invention can effectively improve the efficiency and processing speed of the operating system firewall function, and can determine whether it is a network attack according to the configured business rules, and can effectively reject network access of non-configured business, while realizing the functions of internal and external defense. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Attached Figure 1 This is the operation flow of implementing internal and external firewall functions based on eBPF technology in an embodiment of the present invention;

[0063] Attached Figure 2 is a flowchart of the business processing logic implementation in an embodiment of the present invention;

[0064] Attached Figure 3 This is a module connection block diagram of the second embodiment of the present invention. DETAILED DESCRIPTION

[0065] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.

[0066] Embodiment 1:

[0067] This embodiment proposes a method for implementing an operating system firewall function based on the eBPF technology, which includes the following steps:

[0068] 1. Preparation

[0069] Configure firewall parameters, as shown in Table 1 below;

[0070] Table 1

[0071]

[0072] Translate the configuration parameters into task files for automated drills, as follows:

[0073] Open ports, configure external access to local ports. If it is not an open port, access is prohibited;

[0074] Whitelist, configure trusted IP addresses or IP addresses and ports;

[0075] Blacklist, configure untrusted IP addresses, and do not accept any network requests after configuration;

[0076] The request keyword and the response keyword are keywords contained in the business data part of the network packet, using a segment of characters starting from the head, tail, or a specified position in the middle.

[0077] (II) Combined with Figure 1 , based on the eBPF technology working at the data link layer, to provide protection

[0078] 1) Mount the eBPF hook function that processes the entry data at the network entry point;

[0079] 2) Parse the acquired data packets and extract the contents of the data packets, including protocol type, IP, port, and data packet contents;

[0080] 3) Call the business processing logic to realize the internal and external firewall functions, combined with the attached Figure 2 , the specific implementation process of business processing logic is as follows:

[0081] a) Read configuration parameters, including whitelist, blacklist, request frequency and time limit for adding common IP to blacklist, request frequency and time limit for adding whitelist to blacklist, and time for removal from blacklist;

[0082] b) Check the data packet port, that is, the port configured in the configuration file. If the port is not an open port, directly add the requested IP to the blacklist and discard the requested data packet. If the port is an open port, continue to step c);

[0083] c) Check whether the IP address of the data packet is in the whitelist. If yes, proceed to step d), otherwise jump to step f);

[0084] d) Analyze whether the data packet is the service configured in the configuration file, if yes, continue to step e), otherwise discard the packet and add it to the blacklist;

[0085] e) Determine whether the request in the whitelist exceeds the request frequency. If yes, discard the current data and add it to the blacklist to prevent illegal access from normal IP addresses. Otherwise, release it. If it is not in the whitelist, add it to the whitelist and the process ends;

[0086] f) Determine whether it is on the blacklist, if yes, proceed to step g), otherwise jump to step e);

[0087] g) Determine whether there is no request within the configured time period. If yes, release the request, remove it from the blacklist, and jump to step d). Otherwise, continue to step h);

[0088] h) Determine whether there is a request within the configured time period. If yes, release it, remove it from the blacklist, and jump to step d). Otherwise, update the request time of the blacklist, discard the data packet, and the process ends;

[0089] 4) Packet processing is completed.

[0090] Embodiment 2:

[0091] Combined with Figure 3 This embodiment proposes a device for implementing an operating system firewall function based on the eBPF technology, which includes:

[0092] Configuration module, used to configure firewall parameters;

[0093] Parameter translation module, used to translate configuration parameters into task files for automated drills;

[0094] The protection processing module is used to mount the eBPF hook function for processing entry data at the network entry point, parse the obtained data packets and extract the content in the data packets, call the business processing logic, implement the internal and external firewall functions, and complete the data packet processing.

[0095] In this embodiment, the configured firewall parameters are specifically shown in Table 2 below.

[0096] Table 2

[0097]

[0098]

[0099] In this embodiment, the parameter translation module involved translates the configuration parameters into a task file for automated drills, as follows:

[0100] Open ports, configure external access to local ports. If it is not an open port, access is prohibited;

[0101] Whitelist, configure trusted IP addresses or IP addresses and ports;

[0102] Blacklist, configure untrusted IP addresses, and do not accept any network requests after configuration;

[0103] The request keyword and the response keyword are keywords contained in the business data part of the network packet, using a segment of characters starting from the head, tail, or a specified position in the middle.

[0104] In this embodiment, the protection processing module parses the acquired data packet and extracts the content in the data packet, including the protocol type, IP, port, and data packet content;

[0105] Combined with Figure 2 , the protection processing module calls the business processing logic. The specific implementation process of the business processing logic is as follows:

[0106] a) Read configuration parameters, including whitelist, blacklist, request frequency and time limit for adding common IP to blacklist, request frequency and time limit for adding whitelist to blacklist, and time for removal from blacklist;

[0107] b) Check the data packet port, that is, the port configured in the configuration file. If the port is not an open port, directly add the requested IP to the blacklist and discard the requested data packet. If the port is an open port, continue to step c);

[0108] c) Check whether the IP address of the data packet is in the whitelist. If yes, proceed to step d), otherwise jump to step f);

[0109] d) Analyze whether the data packet is the service configured in the configuration file, if yes, continue to step e), otherwise discard the packet and add it to the blacklist;

[0110] e) Determine whether the request in the whitelist exceeds the request frequency. If yes, discard the current data and add it to the blacklist to prevent illegal access from normal IP addresses. Otherwise, release it. If it is not in the whitelist, add it to the whitelist and the process ends;

[0111] f) Determine whether it is on the blacklist, if yes, proceed to step g), otherwise jump to step e);

[0112] g) Determine whether there is no request within the configured time period. If yes, release the request, remove it from the blacklist, and jump to step d). Otherwise, continue to step h);

[0113] h) Determine whether there is a request within the configured time period. If yes, release it, remove it from the blacklist, and jump to step d). Otherwise, update the request time of the blacklist, discard the data packet, and the process ends.

[0114] In summary, the method and device for realizing the operating system firewall function based on the eBPF technology of the present invention can effectively improve the efficiency and processing speed of the operating system firewall function, and can determine whether it is a network attack according to the configured business rules, and can effectively reject network access for non-configured business, while realizing the functions of both internal and external defense.

[0115] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.

Claims

1. A method for implementing an operating system firewall function based on eBPF technology, characterized in that: The steps include:

1. Preparation Configure firewall parameters; Translate configuration parameters into task files for automated drills; (II) Protection based on eBPF technology working at the data link layer 1) Mount the eBPF hook function that processes the entry data at the network entry point; 2) Parse the acquired data packets and extract the contents of the data packets; 3) Call business processing logic to implement internal and external firewall functions; 4) Packet processing is completed.

2. A method for implementing an operating system firewall function based on eBPF technology according to claim 1, characterized in that: The configured firewall parameters include: open ports, whitelist, blacklist, request keyword, response keyword, blacklist removal time, blacklist entry frequency, and whitelist exit frequency.

3. The method for implementing an operating system firewall function based on eBPF technology according to claim 2, characterized in that: Translate the configuration parameters into task files for automated drills, as follows: Open ports, configure external access to local ports. If it is not an open port, access is prohibited; Whitelist, configure trusted IP addresses or IP addresses and ports; Blacklist, configure untrusted IP addresses, and do not accept any network requests after configuration; The request keyword and the response keyword are keywords contained in the business data part of the network packet, using a segment of characters starting from the head, tail, or a specified position in the middle.

4. The method for implementing an operating system firewall function based on eBPF technology according to claim 2, characterized in that: Execute step 2) to extract the content in the data packet, including the protocol type, IP, port, and data packet content.

5. The method for implementing an operating system firewall function based on eBPF technology according to claim 2, characterized in that: Execute step 3), the specific implementation process of the business processing logic is as follows: a) Read configuration parameters, including whitelist, blacklist, request frequency and time limit for adding common IP to blacklist, request frequency and time limit for adding whitelist to blacklist, and time for removal from blacklist; b) Check the data packet port, that is, the port configured in the configuration file. If the port is not an open port, directly add the requested IP to the blacklist and discard the requested data packet. If the port is an open port, continue to step c); c) Check whether the IP address of the data packet is in the whitelist. If yes, proceed to step d), otherwise jump to step f); d) Analyze whether the data packet is the service configured in the configuration file, if yes, continue to step e), otherwise discard the packet and add it to the blacklist; e) Determine whether the request in the whitelist exceeds the request frequency. If yes, discard the current data and add it to the blacklist to prevent illegal access from normal IP addresses. Otherwise, release it. If it is not in the whitelist, add it to the whitelist and the process ends; f) Determine whether it is on the blacklist, if yes, proceed to step g), otherwise jump to step e); g) Determine whether there is no request within the configured time period. If yes, release the request, remove it from the blacklist, and jump to step d). Otherwise, continue to step h); h) Determine whether there is a request within the configured time period. If yes, release it, remove it from the blacklist, and jump to step d). Otherwise, update the request time of the blacklist, discard the data packet, and the process ends.

6. A device for implementing an operating system firewall function based on eBPF technology, characterized in that: It includes: Configuration module, used to configure firewall parameters; Parameter translation module, used to translate configuration parameters into task files for automated drills; The protection processing module is used to mount the eBPF hook function for processing entry data at the network entry point, parse the obtained data packets and extract the content in the data packets, call the business processing logic, implement the internal and external firewall functions, and complete the data packet processing.

7. The device for implementing operating system firewall function based on eBPF technology according to claim 6, characterized in that: The firewall parameters configured by the configuration module include: open ports, whitelist, blacklist, request keyword, response keyword, blacklist removal time, blacklist entry frequency and whitelist exit frequency.

8. The device for implementing operating system firewall function based on eBPF technology according to claim 7, characterized in that: The parameter translation module translates the configuration parameters into the task files for the automated drills, as follows: Open ports, configure external access to local ports. If it is not an open port, access is prohibited; Whitelist, configure trusted IP addresses or IP addresses and ports; Blacklist, configure untrusted IP addresses, and do not accept any network requests after configuration; The request keyword and the response keyword are keywords contained in the business data part of the network packet, using a segment of characters starting from the head, tail, or a specified position in the middle.

9. The device for implementing operating system firewall function based on eBPF technology according to claim 7, characterized in that: The protection processing module parses the acquired data packets and extracts the contents in the data packets, including the protocol type, IP, port, and data packet contents.

10. The device for implementing operating system firewall function based on eBPF technology according to claim 7, characterized in that: The protection processing module calls the business processing logic, and the specific implementation process of the business processing logic is as follows: a) Read configuration parameters, including whitelist, blacklist, request frequency and time limit for adding common IP to blacklist, request frequency and time limit for adding whitelist to blacklist, and time for removal from blacklist; b) Check the data packet port, that is, the port configured in the configuration file. If the port is not an open port, directly add the requested IP to the blacklist and discard the requested data packet. If the port is an open port, continue to step c); c) Check whether the IP address of the data packet is in the whitelist. If yes, proceed to step d), otherwise jump to step f); d) Analyze whether the data packet is the service configured in the configuration file, if yes, continue to step e), otherwise discard the packet and add it to the blacklist; e) Determine whether the request in the whitelist exceeds the request frequency. If yes, discard the current data and add it to the blacklist to prevent illegal access from normal IP addresses. Otherwise, release it. If it is not in the whitelist, add it to the whitelist and the process ends; f) Determine whether it is on the blacklist, if yes, proceed to step g), otherwise jump to step e); g) Determine whether there is no request within the configured time period. If yes, release the request, remove it from the blacklist, and jump to step d). Otherwise, continue to step h); h) Determine whether there is a request within the configured time period. If yes, release it, remove it from the blacklist, and jump to step d). Otherwise, update the request time of the blacklist, discard the data packet, and the process ends.

Citation Information

Patent Citations

  • Firewall management system, client, server end and method

    CN105100124A

  • Network application firewall system and realization method thereof

    CN105871919A

  • Industrial firewall strategy planning method and system and electronic equipment

    CN115603997A

  • Linux firewall system implementation method based on eBPF and XDP technologies

    CN116668140A

  • Network security protection method and system, computing device and storage medium

    CN117938452A