Patent Description:
In a wireless communication system, radio resource control (radio resource control, RRC) signaling or user plane data may be sent between user equipment (user equipment, UE) and a base station. However, attackers may deploy a false base station between the UE and the base station to eavesdrop, tamper with, forge, inject, and release an air interface message, causing a DoS attack to a terminal and a network.

A man-in-the-middle is a type of false base station, including a false base station part function and a false UE part function. If UE is in an idle state, when the UE approaches a false base station, and detects that signal quality of a cell of the false base station is good and meets a cell reselection condition, the UE triggers a cell reselection process and camps on the cell of the false base station. If UE is in a connected state, when the UE approaches a false base station, and detects that signal quality of a cell of the false base station is good, the UE reports a measurement result to a serving cell. The serving cell triggers handover of the UE to the cell of the false base station, to enable the UE to camp on the cell of the false base station. The false UE part function is used to forward or modify communication data of real UE, access a real base station as the real UE, and communicate with an access and mobility management function (access and mobility management function, AMF) based on an N2 protocol. It is usually difficult for a network side and a terminal side to perceive a man-in-the-middle.

A current method for discovering a man-in-the-middle is usually as follows: A hash HASH value of a received master information block (master information block, MIB)/system information block (system information block, SIB) is calculated by UE, and the hash value of the MIB/SIB is carried in a measurement report (measurement report, MR)/logged MR to be reported to a real base station. The real base station calculates a hash value of the MIB/SIB and compares the hash value with the value reported by the UE; and if the two values are inconsistent, determines that a man-in-the-middle exists. <CIT> discloses information protection to detect fake base stations. <CIT> discloses an information processing method and device. <CIT> discloses a synchronization method and system for an access layer security algorithm.

However, when the man-in-the-middle completely imitates the MIB/SIB of the real base station, the method cannot be used to detect the man-in-the-middle.

Therefore, providing a man-in-the-middle detection method that can prevent a man-in-the-middle from bypassing detection through a mechanism of the man-in-the-middle is an urgent problem to be resolved currently.

This application provides a man-in-the-middle detection method and apparatus, to effectively improve an air interface man-in-the-middle detection rate and prevent a man-in-the-middle from bypassing a detection mechanism through technical means.

According to a first aspect, a man-in-the-middle detection method is provided. The method includes: A base station receives, in a first physical frame, a first radio resource control RRC message from user equipment UE; the base station receives a second RRC message from the UE, where the second RRC message includes frame information of a second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by the UE and the base station; and the base station determines whether the first physical frame matches the second physical frame.

With reference to the first aspect, in a first possible implementation of the first aspect, the frame information of the second physical frame includes a frame number and a subframe number of the second physical frame.

With reference to the first possible implementation of the first aspect, in a second possible implementation of the first aspect, that the base station determines whether the first physical frame matches the second physical frame includes: If a frame number of the first physical frame is the same as the frame number of the second physical frame and a subframe number of the first physical frame is the same as the subframe number of the second physical frame, the base station determines that the first physical frame matches the second physical frame; otherwise, the base station determines that the first physical frame does not match the second physical frame.

With reference to the first aspect or either of the first and second possible implementations of the first aspect, in a third possible implementation of the first aspect, after that a base station receives, in a first physical frame, a first radio resource control RRC message from UE, the method further includes: The base station stores frame information of the first physical frame.

With reference to the first aspect or any one of the first to third possible implementations of the first aspect, in a fourth possible implementation of the first aspect, before that a base station receives, in a first physical frame, a first radio resource control RRC message from UE, the method further includes: The base station establishes the AS security context with the UE.

With reference to the first aspect or any one of the first to fourth possible implementations of the first aspect, in a fifth possible implementation of the first aspect, before that a base station receives, in a first physical frame, a first RRC message from UE, the method further includes: The base station sends indication information to the UE, where the indication information indicates the UE to enable man-in-the-middle detection.

According to a second aspect, a man-in-the-middle detection method is provided. The method includes: User equipment UE sends, in a second physical frame, a first radio resource control RRC message to a base station; and the UE sends a second RRC message to the base station, where the second RRC message includes frame information of the second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by the UE and the base station.

With reference to the second aspect, in a first possible implementation of the second aspect, the frame information of the second physical frame includes a frame number and a subframe number of the second physical frame.

With reference to the second aspect or the first possible implementation of the second aspect, in a second possible implementation of the second aspect, before that user equipment UE sends, in a second physical frame, a first radio resource control RRC message to a base station, the method further includes: The UE receives downlink control information DCI, where the DCI is used to determine the frame information of the second physical frame; and the UE stores the frame information of the second physical frame.

With reference to the second aspect or either of the first and second possible implementations of the second aspect, in a third possible implementation of the first aspect, before that user equipment UE sends, in a second physical frame, a first radio resource control RRC message to a base station, the method further includes: The UE accesses the base station, and establishes the AS security context with the base station.

With reference to the second aspect or any one of the first to third possible implementations of the second aspect, in a fourth possible implementation of the second aspect, that user equipment UE sends, in a second physical frame, a first radio resource control RRC message to a base station includes: If a preset rule is met, the UE sends, in the second physical frame, the first RRC message to the base station.

With reference to the fourth possible implementation of the second aspect, in a fifth possible implementation of the second aspect, the preset rule includes: The UE receives indication information sent by the base station, where the indication information indicates the UE to enable man-in-the-middle detection; or the UE determines that user plane integrity protection between the UE and the base station is not enabled.

According to a third aspect, a man-in-the-middle detection method is provided. The method includes: User equipment UE sends, in a third physical frame, a third radio resource control RRC message to a base station; the UE receives a fourth RRC message from the base station, where the fourth RRC message includes frame information of a fourth physical frame; the UE determines whether the third physical frame matches the fourth physical frame; and the UE sends a fifth RRC message to the base station, where the fifth RRC message indicates whether the third physical frame matches the fourth physical frame, and security protection is performed on the third RRC message, the fourth RRC message, and the fifth RRC message by using an access stratum AS security context established by the UE and the base station.

With reference to the third aspect, in a first possible implementation of the third aspect, the frame information of the fourth physical frame includes a frame number and a subframe number of the fourth physical frame.

With reference to the first possible implementation of the third aspect, in a second possible implementation of the third aspect, that the UE determines whether the third physical frame matches the fourth physical frame includes: If a frame number of the third physical frame is the same as the frame number of the fourth physical frame and a subframe number of the third physical frame is the same as the subframe number of the fourth physical frame, the UE determines that the third physical frame matches the fourth physical frame; otherwise, the UE determines that the third physical frame does not match the fourth physical frame.

With reference to the third aspect or either of the first and second possible implementations of the third aspect, in a third possible implementation of the third aspect, before that user equipment UE sends, in a third physical frame, a third radio resource control RRC message to a base station, the method further includes: The UE receives downlink control information DCI, where the DCI is used to determine frame information of the third physical frame, and the frame information of the third physical frame includes the frame number and the subframe number of the third physical frame; and the UE stores the frame information of the third physical frame.

With reference to the third aspect or any one of the first to third possible implementations of the third aspect, in a fourth possible implementation of the third aspect, before that user equipment UE sends, in a third physical frame, a third radio resource control RRC message to a base station, the method further includes: The UE accesses the base station, and establishes the AS security context with the base station.

With reference to the third aspect or any one of the first to fourth possible implementations of the third aspect, in a fifth possible implementation of the third aspect, that user equipment UE sends, in a third physical frame, a third radio resource control RRC message to a base station includes: If a preset rule is met, the UE sends, in the second physical frame, the third RRC message to the base station.

With reference to the third aspect or any one of the first to fifth possible implementations of the third aspect, in a sixth possible implementation of the third aspect, the first preset rule includes: The UE receives indication information sent by the base station, where the indication information indicates the UE to enable man-in-the-middle detection; or the UE determines that user plane integrity protection between the UE and the base station is not enabled.

According to a fourth aspect, a man-in-the-middle detection method is provided. The method includes: A base station receives, in a fourth physical frame, a third RRC message from user equipment UE; the base station sends a fourth RRC message to the UE, where the fourth RRC message includes frame information of the fourth physical frame; the base station receives a fifth RRC message sent by the UE; and the base station determines, based on the fifth RRC message, whether a man-in-the-middle exists between the base station and the UE.

With reference to the fourth aspect, in a first possible implementation of the fourth aspect, the fifth RRC message indicates whether a third physical frame matches the fourth physical frame, and the third physical frame is a physical frame in which the UE sends the third RRC message. That the base station determines, based on the fifth RRC message, whether a man-in-the-middle exists between the base station and the UE includes: If the third physical frame does not match the fourth physical frame, the base station determines that a man-in-the-middle exists between the base station and the UE; or if the third physical frame matches the fourth physical frame, the base station determines that no man-in-the-middle exists between the base station and the UE.

With reference to the fourth aspect or the first possible implementation of the fourth aspect, in a second possible implementation of the fourth aspect, the frame information of the fourth physical frame includes a frame number and a subframe number of the fourth physical frame.

With reference to the fourth aspect or either of the first and second possible implementations of the fourth aspect, in a third possible implementation of the third aspect, before that a base station receives, in a fourth physical frame, a third RRC message sent by user equipment UE, the method further includes: The base station establishes an AS security context with the UE.

With reference to the fourth aspect or any one of the first to third possible implementations of the fourth aspect, in a fifth possible implementation of the third aspect, before that a base station receives, in a fourth physical frame, a third RRC message from user equipment UE, the method further includes: The base station sends indication information to the UE, where the indication information indicates the UE to enable man-in-the-middle detection.

According to a fifth aspect, a man-in-the-middle detection apparatus is provided. The apparatus includes: a transceiver module, configured to receive, in a first physical frame, a first radio resource control RRC message from user equipment UE, where the transceiver module is further configured to receive a second RRC message from the UE, where the second RRC message includes frame information of a second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by the UE and a base station; and a processing module, configured to determine whether the first physical frame matches the second physical frame.

With reference to the fifth aspect, in a first possible implementation of the fifth aspect, the frame information of the second physical frame includes a frame number and a subframe number of the second physical frame.

With reference to the first possible implementation of the fifth aspect, in a second possible implementation of the fifth aspect, the processing module is specifically configured to: if a frame number of the first physical frame is the same as the frame number of the second physical frame and a subframe number of the first physical frame is the same as the subframe number of the second physical frame, determine, by the base station, that the first physical frame matches the second physical frame; otherwise, determine, by the base station, that the first physical frame does not match the second physical frame.

With reference to the fifth aspect or either of the first and second possible implementations of the fifth aspect, in a third possible implementation of the fifth aspect, the processing module is further configured to store frame information of the third physical frame.

With reference to the fifth aspect or any one of the first to third possible implementations of the fifth aspect, in a fourth possible implementation of the fifth aspect, the processing module is further configured to establish the AS security context with the UE.

With reference to the fifth aspect or any one of the first to fourth possible implementations of the fifth aspect, in a fifth possible implementation of the fifth aspect, the transceiver module is further configured to send indication information to the UE, where the indication information indicates the UE to enable man-in-the-middle detection.

According to a sixth aspect, a man-in-the-middle detection apparatus is provided. The apparatus includes a transceiver module, configured to send, in a second physical frame, a first radio resource control RRC message to a base station. The transceiver module is further configured to send a second RRC message to the base station. The second RRC message includes frame information of the second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by UE and the base station.

With reference to the sixth aspect, in a first possible implementation of the sixth aspect, the frame information of the second physical frame includes a frame number and a subframe number of the second physical frame.

With reference to the sixth aspect or the first possible implementation of the sixth aspect, in a second possible implementation of the sixth aspect, the transceiver module is further configured to receive downlink control information DCI, where the DCI is used to determine the frame information of the second physical frame. The apparatus further includes a processing module, where the processing module is configured to store the frame information of the second physical frame.

With reference to the sixth aspect or either of the first and second possible implementations of the fifth aspect, in a third possible implementation of the sixth aspect, the processing module is further configured to access the base station and establish the AS security context with the base station.

With reference to the sixth aspect or any one of the first to third possible implementations of the sixth aspect, in a fourth possible implementation of the sixth aspect, the transceiver module is specifically configured to: if a preset rule is met, send, by the UE in the second physical frame, the first RRC message to the base station.

With reference to the fourth possible implementation of the sixth aspect, in a fifth possible implementation of the sixth aspect, the preset rule includes: The UE receives indication information sent by the base station, where the indication information indicates the UE to enable man-in-the-middle detection; or the UE determines that user plane integrity protection between the UE and the base station is not enabled.

According to a seventh aspect, a man-in-the-middle detection apparatus is provided. The apparatus includes: a transceiver module, configured to send, in a third physical frame, a third radio resource control RRC message to a base station. The transceiver module is further configured to receive a fourth RRC message from the base station, where the fourth RRC message includes frame information of a fourth physical frame; and the transceiver module is further configured to send a fifth RRC message to the base station, where the fifth RRC message indicates whether the third physical frame matches the fourth physical frame, and security protection is performed on the third RRC message, the fourth RRC message, and the fifth RRC message by using an access stratum AS security context established by UE and the base station.

With reference to the seventh aspect, in a first possible implementation of the seventh aspect, the frame information of the fourth physical frame includes a frame number and a subframe number of the fourth physical frame.

With reference to the seventh aspect or the first possible implementation of the seventh aspect, in a second possible implementation of the seventh aspect, the processing module is specifically configured to: if a frame number of the third physical frame is the same as the frame number of the fourth physical frame and a subframe number of the third physical frame is the same as the subframe number of the fourth physical frame, determine, by the UE, that the third physical frame matches the fourth physical frame; otherwise, determine, by the UE, that the third physical frame does not match the fourth physical frame.

With reference to the seventh aspect or either of the first and second possible implementations of the seventh aspect, in a third possible implementation of the seventh aspect, the transceiver module is further configured to receive downlink control information DCI, where the DCI is used to determine frame information of the third physical frame, and the frame information of the third physical frame includes the frame number and the subframe number of the third physical frame.

The processing module is further configured to store the frame information of the third physical frame.

With reference to the seventh aspect or any one of the first to third possible implementations of the seventh aspect, in a fourth possible implementation of the seventh aspect, the processing module is further configured to access the base station and establish the AS security context with the base station.

With reference to the seventh aspect or any one of the first to fourth possible implementations of the seventh aspect, in a fifth possible implementation of the seventh aspect, the first preset rule includes:.

The UE receives indication information sent by the base station, where the indication information indicates the UE to enable man-in-the-middle detection; or the UE determines that user plane integrity protection between the UE and the base station is not enabled.

According to an eighth aspect, a man-in-the-middle detection apparatus is provided. The apparatus includes: a transceiver module, configured to receive, in a fourth physical frame, a third RRC message from user equipment UE, where the transceiver module is further configured to send a fourth RRC message to the UE, where the fourth RRC message includes frame information of the fourth physical frame; and the transceiver module is further configured to receive a fifth RRC message sent by the UE; and a processing module, configured to determine, based on the fifth RRC message, whether a man-in-the-middle exists between a base station and the UE.

With reference to the eighth aspect, in a first possible implementation of the eighth aspect, the fifth RRC message indicates whether a third physical frame matches the fourth physical frame, and the third physical frame is a physical frame in which the UE sends the third RRC message. The processing module is specifically configured to: if the third physical frame does not match the fourth physical frame, determine that the man-in-the-middle exists between the base station and the UE; or if the third physical frame matches the fourth physical frame, determine that no man-in-the-middle exists between the base station and the UE.

With reference to the eighth aspect or the first possible implementation of the eighth aspect, in a second possible implementation of the eighth aspect, the frame information of the fourth physical frame includes a frame number and a subframe number of the fourth physical frame.

With reference to the eighth aspect or either of the first and second possible implementations of the eighth aspect, in a third possible implementation of the eighth aspect, the processing module is further configured to establish an AS security context with the UE.

With reference to the eighth aspect or any one of the first to third possible implementations of the eighth aspect, in a fourth possible implementation of the eighth aspect, the transceiver module is further configured to send indication information to the UE, where the indication information indicates the UE to enable man-in-the-middle detection.

According to a ninth aspect, a communication apparatus is provided. The apparatus includes a processor, configured to execute a computer program stored in a memory, to enable the communication apparatus to perform the communication method in any one of the first to fifth possible implementations of the first aspect, or perform the communication method in any one of the first to fifth possible implementations of the second aspect, or perform the communication method in any one of the first to fourth possible implementations of the third aspect, or perform the communication method in any one of the first to fourth possible implementations of the fourth aspect.

According to a tenth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program. When the computer program is run on a computer, the computer is enabled to perform the communication method in any one of the first to fifth possible implementations of the first aspect, or perform the communication method in any one of the first to the fifth possible implementations of the second aspect, or perform the communication method in any one of the first to fourth possible implementations of the third aspect, or perform the communication method in any one of the first to fourth possible implementations of the fourth aspect.

According to an eleventh aspect, a chip system is provided. The chip system includes a processor, configured to invoke a computer program from a memory and run the computer program, to enable the communication device installed with the chip system to perform the communication method in any one of the first to fifth possible implementations of the first aspect, or perform the communication method in any one of the first to fifth possible implementations of the second aspect, or perform the communication method in any one of the first to fourth possible implementations of the third aspect, or perform the communication method in any one of the first to fourth possible implementations of the fourth aspect.

The following describes technical solutions in embodiments of this application with reference to the accompanying drawings in embodiments of this application.

The technical solutions in embodiments of this application may be applied to various communication systems, for example, a long term evolution (long term evolution, LTE) system, an LTE frequency division duplex (frequency division duplex, FDD) system, an LTE time division duplex (time division duplex, TDD), a universal mobile telecommunications system (universal mobile telecommunications system, UMTS), and a new radio (new radio, NR) system.

The following describes a structure of a communication system in this application with reference to <FIG>. As shown in <FIG>, the communication system includes but is not limited to the following network elements.

The UE in embodiments of this application may also be referred to as a mobile station (mobile station, MS), a mobile terminal (mobile terminal, MT), an access terminal, a subscriber unit, a subscriber station, a mobile station, a remote station, a remote terminal, a mobile device, a user terminal, a terminal, a wireless communication device, a user agent, a user apparatus, and the like.

The UE may be a device that provides a voice/data connectivity for a user, for example, a handheld device or a vehicle-mounted device that has a wireless connection function. Currently, examples of some terminals are a mobile phone (mobile phone), a tablet computer, a laptop computer, a palmtop computer, a mobile internet device (mobile internet device, MID), a wearable device, a virtual reality (virtual reality, VR) device, an augmented reality (augmented reality, AR) device, a wireless terminal in industrial control (industrial control), a wireless terminal in self-driving (self-driving), a wireless terminal in remote medical surgery (remote medical surgery), a wireless terminal in a smart grid (smart grid), a wireless terminal in transportation safety (transportation safety), a wireless terminal in a smart city (smart city), a wireless terminal in a smart home (smart home), a cellular phone, a cordless telephone set, a session initiation protocol (session initiation protocol, SIP) phone, a wireless local loop (wireless local loop, WLL) station, a personal digital assistant (personal digital assistant, PDA), a handheld device having a wireless communication function, a calculating device or another processing device connected to a wireless modem, a vehicle-mounted device, a wearable device, UE in a future <NUM> network, or UE in a future evolved public land mobile network (public land mobile network, PLMN). This is not limited in embodiments of this application.

By way of example, and not limitation, in embodiments of this application, the UE may alternatively be a wearable device. The wearable device may also be referred to as a wearable intelligent device, and is a general term of a wearable device that is intelligently designed and developed for daily wear by using a wearable technology, for example, glasses, gloves, a watch, clothing, and shoes. The wearable device is a portable device that can be directly worn on a body or integrated into clothes or an accessory of a user. The wearable device is not only a hardware device, but also implements a powerful function through software support, data exchange, and cloud interaction. A generalized wearable intelligent device includes a full-featured and large-size device that can implement complete or partial functions without depending on a smartphone, such as a smart watch or smart glasses, and a device that focuses on only one type of application functions and needs to work with another device such as a smartphone, for example, various smart bands or smart jewelry for monitoring a physical sign.

In addition, in embodiments of this application, the UE may alternatively be UE in an internet of things (Internet of things, IoT) system. An IoT is an important part of future information technology development. A main technical feature of the IoT is that an article is connected to a network by using a communication technology, to implement an intelligent network for human-machine interconnection and thing-thing interconnection.

In embodiments of this application, the IoT technology can implement massive connections, in-depth coverage, and terminal power saving by using, for example, a narrow band (narrow band) NB technology. For example, an NB may include one resource block (resource block, RB). In other words, a bandwidth of the NB is only <NUM> KB. To implement massive access, a terminal needs to perform discrete access. According to a communication method in embodiments of this application, a congestion problem that occurs in the IoT technology when massive terminals access a network through the NB can be effectively resolved.

In addition, in embodiments of this application, the UE may further communicate with UE in another communication system. For example, the UEs perform inter-device communication. For example, the UE may further transmit (for example, send and/or receive) a time synchronization packet with UE in another communication system.

In addition, the base station in embodiments of this application may be a device configured to communicate with UE. The base station may also be referred to as an access network device or a radio access network device. For example, the base station may be an evolved NodeB (evolved NodeB, eNB or eNodeB) in an LTE system, or a radio controller in a cloud radio access network (cloud radio access network, CRAN) scenario. Alternatively, the base station may be a relay station, an access point, a vehicle-mounted device, a wearable device, a base station in a future <NUM> network, a base station in a future evolved PLMN network, an access point (access point, AP) in a WLAN, or a gNB in a new radio (new radio, NR) system. This is not limited in embodiments of this application.

In addition, in embodiments of this application, the base station is a device in a RAN, that is, a RAN node that enables UE to access a wireless network. For example, by way of example, and not limitation, the base station may be a gNB, a transmission reception point (transmission reception point, TRP), an evolved NodeB (evolved NodeB, eNB), a radio network controller (radio network controller, RNC), a NodeB (NodeB, NB), a base station controller (base station controller, BSC), a base transceiver station (base transceiver station, BTS), a home base station (such as a home evolved NodeB, or home NodeB, HNB), or a base band unit (base band unit, BBU). In a network structure, a network device may include a central unit (central unit, CU) node, a distributed unit (distributed unit, DU) node, a RAN device including a CU node and a DU node, or a RAN device including a CU control plane node (CU-CP node), a CU user plane node (CU-UP node), and a DU node.

The base station serves a cell. UE communicates with the base station by using a transmission resource (for example, a frequency domain resource or a spectrum resource) used for the cell. The cell may be a cell corresponding to the base station (for example, the base station). The cell may belong to a macro base station, or a base station corresponding to a small cell (small cell). The small cell herein may include a metro cell (metro cell), a micro cell (micro cell), a pico cell (pico cell), a femto cell (femto cell), or the like. These small cells have features of small coverage and low transmit power, and are applicable to providing a high-speed data transmission service.

In addition, a plurality of cells may simultaneously operate in a same frequency on a carrier in an LTE system or a <NUM> system. In some special scenarios, it may also be considered that a concept of the carrier is equivalent to that of the cell. For example, in a carrier aggregation (carrier aggregation, CA) scenario, when a secondary component carrier is configured for UE, a carrier index of the secondary component carrier and a cell identifier (cell identifier, Cell ID) of a secondary cell working on the secondary component carrier are both carried. In this case, it may be considered that the concept of the carrier is equivalent to that of the cell. For example, for UE, accessing a carrier is equivalent to accessing a cell.

The access management function entity is mainly configured to perform mobility management, access management, and the like, and may be configured to implement functions other than a session management function in functions of a mobility management entity (mobility management entity, MME) in an LTE system, for example, functions such as lawful interception and access authorization/authentication.

In a <NUM> communication system, an access management network element may be an access management function (access and mobility management function, AMF) entity.

In a future communication system, the access management function entity may still be an AMF entity, or may have another name. This is not limited in this application.

It may be understood that the entities or the functions may be network elements in a hardware device, may be software functions run on dedicated hardware, or may be virtualized functions instantiated on a platform (for example, a cloud platform).

It should be understood that the foregoing network elements or entities included in the communication system are merely examples for descriptions. This is not particularly limited in this application.

<FIG> is an architectural diagram of working of a man-in-the-middle. It can be learned from <FIG> that the man-in-the-middle includes a false base station part and a false UE part. The false base station part is configured to attract UE to camp on a man-in-the-middle cell, and the false UE part is configured to access a real base station, and forward or modify communication data of real UE. An AMF network element is a network element that is mainly responsible for access and mobility management. A base station (a gNB in <FIG>) and the AMF are connected through an N2 interface. The interface is similar to an S1 interface, and transmits a message exchanged between a RAN and the AMF. UE communicates with the AMF through an N1/NAS interface to transmit a message exchanged between the UE and the AMF. Usually, the RAN forwards the message to the AMF. The UE and the base station are connected through a Uu interface, and the UE and the base station may send RRC signaling and user plane data. The base station is connected to the AMF through the N2 interface, and the base station communicates with the AMF based on an N2 protocol.

Such a man-in-the-middle may eavesdrop, tamper with, forge, inject, and release an air interface message, causing a DoS attack to a terminal and a network. It is usually difficult for a network side and a terminal side to perceive a man-in-the-middle.

For ease of description, the following first describes a physical frame in air interface communication by using a frame structure in an LTE system and an NR system as an example.

The physical frame usually refers to a protocol data unit at a data link layer. The physical frame includes several parts that perform different functions. The frame structure refers to frames that can form different repetition periodicities based on different transmitted information. To meet a requirement of uplink and downlink time conversion in time division multiplexing, in TD-LTE, a dedicated radio frame structure is designed. In TD-LTE time domain, there are two types of frame structures for periodic simultaneous transmission with a quantity of uplink and downlink subframes in a standard configuration: a radio frame and a half-frame. Duration of the radio frame is <NUM>, and duration of the half-frame is <NUM>. One radio frame includes two half-frames. Each half-frame includes five subframes whose duration is <NUM>, each subframe includes two slots whose duration is <NUM>, and each slot includes six or seven CP+OFDM symbols based on different cyclic prefix CP duration.

Compared with a fixed <NUM> frame structure, the most distinctive feature of a <NUM> frame structure is flexibility and variability. A <NUM> frame uses a hierarchical structure and includes two parts: a fixed architecture and a flexible architecture. The fixed architecture is the same as that in <NUM>, and includes a radio frame whose duration is <NUM> and a subframe whose duration is <NUM>. Each frame is divided into two half-frames. The first half-frame includes subframes <NUM> to <NUM>, and the second half-frame includes subframes <NUM> to <NUM>. Each subframe includes several slots.

In an LTE system or an NR system, a system frame number (system frame number, SFN) ranges from <NUM> to <NUM>, that is, a basic data sending periodicity is <NUM> frames. A subframe number ranges from <NUM> to <NUM>, that is, a sending periodicity of a part of control information is <NUM> subframes.

The following describes in detail a man-in-the-middle detection method in this application with reference to <FIG>.

<FIG> is a schematic flowchart of a man-in-the-middle detection method <NUM> according to an embodiment of this application. It can be learned from <FIG> that the method <NUM> includes the following steps.

S110: A base station receives, in a first physical frame, a first RRC message sent by UE.

S120: The base station receives a second RRC message sent by the UE, where the second RRC message includes frame information of a second physical frame.

S130: The base station determines whether the first physical frame matches the second physical frame.

Specifically, after successfully establishing an AS security context with the UE, the base station receives, in the first physical frame, the first RRC message from the UE. Then, the base station receives the second RRC message on which security protection is performed from the UE. The UE provides the frame information of the second physical frame for the base station by using the second RRC message. The frame information of the second physical frame is a physical frame in which the UE sends the first RRC message. When a man-in-the-middle attack exists, air interface communication between the base station and the UE is intercepted by the man-in-the-middle. An air interface between the UE and a false base station and an air interface between false UE and the base station are independent of each other, that is, the base station cannot directly receive the first RRC message sent by the UE. The man-in-the-middle receives the first RRC message through the false base station, and forwards the first RRC message to the base station through the false UE. Security protection is performed on the first RRC message by using an access stratum security context established by the UE and the base station. Therefore, the man-in-the-middle cannot crack or tamper with the first RRC message. After the man-in-the-middle attack occurs between the UE and the base station, a physical frame in which the UE sends an uplink message cannot be consistent with a physical frame in which the base station receives the uplink message. Therefore, when the first physical frame matches the second physical frame, the base station determines that no man-in-the-middle exists between the UE and the base station. When the first physical frame does not match the second physical frame, the base station determines that a man-in-the-middle exists between the UE and the base station.

Therefore, according to the man-in-the-middle detection method in this embodiment of this application, whether the man-in-the-middle exists in the air interface communication is determined by determining whether the physical frame in which the UE sends the uplink message matches the physical frame in which the base station receives the uplink message, to prevent the man-in-the-middle from bypassing detection through a mechanism of the man-in-the-middle and improve a man-in-the-middle detection rate.

According to the method <NUM>, a basis of the man-in-the-middle detection method in this embodiment of this application is as follows: When the man-in-the-middle attack exists between the UE and the base station, the physical frame in which the UE sends the uplink message cannot match the physical frame in which the base station receives the uplink message. In other words, frame information of the physical frame in which the UE sends the uplink message is inconsistent with frame information of the physical frame in which the base station receives the uplink message. For example, in an uplink scheduling request mechanism shown in <FIG>, when the man-in-the-middle exists between the UE and the base station, an uplink message, for example, the first RRC message, sent by the UE to the base station cannot be directly received by the base station. The base station can receive only the first RRC message transparently transmitted by the man-in-the-middle. In this case, frame information of a physical frame in which the man-in-the-middle sends the uplink message through false UE cannot be consistent with frame information of a physical frame in which real UE sends the uplink message. Specifically, the process <NUM> shown in <FIG> includes the following steps.

S210: The UE sends a first scheduling request (scheduling request, SR) to the man-in-the-middle.

Specifically, when the man-in-the-middle attack exists, the UE and the base station are indirectly connected through the man-in-the-middle, that is, the man-in-the-middle establishes connections to the real UE and a real base station separately through the false base station and the false UE. After the connections are established, the UE sends the first SR to the false base station to apply for an uplink transmission resource.

S220: The man-in-the-middle sends first downlink control information (downlink control information, DCI) to the UE.

Specifically, after receiving the first SR sent by the UE, the man-in-the-middle sends the first DCI to the UE, and indicates an appropriate available resource to the UE by using the first DCI.

S230: The UE sends the first RRC message to the man-in-the-middle.

Specifically, the UE receives the first DCI sent by the man-in-the-middle, determines a physical frame a based on the first DCI, and sends the first RRC message to the man-in-the-middle in the physical frame a.

For example, after receiving the first DCI in a subframe n, the UE sends the first RRC message to the man-in-the-middle in a subframe n+x. A physical frame in which the subframe n+x is located is the physical frame a. It should be understood that in an LTE system, x is a value defined in a protocol, and in a unified configuration, the value of x is fixed. Specifically, for example, in a frequency division duplex (frequency division duplex, FDD) scenario, the value of x is fixed to <NUM>. For details, refer to chapter <NUM> of the protocol 3GPP TS <NUM>. For another example, in an NR system, the UE receives the first DCI, where the first DCI carries an information parameter, and the UE determines the value of x based on the information parameter. For a specific determination method, refer to chapter <NUM> of the protocol 3GPP TS <NUM>.

S240: The man-in-the-middle sends the first SR to the base station.

Specifically, after receiving the first SR sent by the UE in step S210, the man-in-the-middle reports the first SR to the real base station through the false UE.

S250: The base station sends second DCI to the man-in-the-middle.

Specifically, after receiving the first SR sent by the false UE, the base station sends the second DCI to the man-in-the-middle to indicate an appropriate available resource for the false UE.

S260: The man-in-the-middle sends the first RRC message to the base station.

Specifically, the man-in-the-middle receives the second DCI sent by the base station, determines a physical frame b based on the second DCI, and sends the first RRC message to the base station in the physical frame b.

It should be understood that the physical frame a is a time domain resource location indicated by the man-in-the-middle for the UE, and the physical frame b is a time domain resource location indicated by the base station for the man-in-the-middle. Because the man-in-the-middle cannot predict a specific location of the physical frame b indicated by the base station, the physical frame a cannot match the physical frame b. Therefore, when the man-in-the-middle attack exists, the physical frame in which the UE sends the uplink message cannot match the physical frame in which the base station receives the uplink message.

<FIG> is a schematic flowchart of a man-in-the-middle detection method <NUM> according to an embodiment of this application when a man-in-the-middle attack exists between UE and a base station. It can be learned from <FIG> that the method <NUM> includes the following steps.

S310: The UE establishes an AS security context with the base station.

Specifically, the UE accesses the base station, that is, the UE establishes an indirect connection to the base station through the man-in-the-middle, and then the UE establishes the access stratum AS security context with the base station. It should be understood that, after the UE establishes the AS security context with the base station, security protection is performed on all RRC messages, and the man-in-the-middle cannot tamper with the RRC message sent between the UE and the base station. It should be understood that the security protection includes RRC integrity protection and RRC confidentiality protection. The RRC integrity protection can ensure that the RRC message is not tampered with in a transmission process, and the RRC confidentiality protection can ensure that information content of the RRC message is not disclosed in the transmission process.

S320: The man-in-the-middle sends third DCI to the UE, where the third DCI is used to determine a physical frame p for sending the RRC message by the UE.

It should be understood that, before S320, the UE sends a buffer status report (buffer status report, BSR) to the man-in-the-middle to indicate a data volume of an uplink buffer, and then the man-in-the-middle sends the third DCI to the UE to allocate an appropriate available resource to the UE. The UE determines the physical frame p based on the third DCI. Specifically, for example, in an NR system, the UE receives the third DCI in a physical frame c, a frame number and a subframe number of the physical frame c are <NUM> and <NUM> respectively, and time indicated by the physical frame c is <NUM>*<NUM>+<NUM>=<NUM>. The third DCI carries an information parameter. The UE obtains, through calculation based on the information parameter, that a value of x is <NUM>, and time indicated by a physical frame e is <NUM>+<NUM>=<NUM>. Therefore, a frame number and a subframe number of the physical frame e are <NUM> and <NUM> respectively.

Optionally, after determining the physical frame p based on the third DCI, the UE stores frame information of the physical frame p, where the frame information of the physical frame p includes a frame number and a subframe number of the physical frame p.

It should be understood that, before step S320, if a first preset rule is met, the UE enables man-in-the-middle detection. The enabling man-in-the-middle detection means that the UE performs the method mentioned in this application. For example, the enabling man-in-the-middle detection may include: The UE sends a first physical frame query request message and a second physical frame query request message that carries the frame information of the physical frame p.

The first preset rule includes: The UE receives indication information from the base station, where the indication information indicates the UE to enable man-in-the-middle detection; or the UE determines that user plane integrity protection between the UE and the base station is not enabled. It should be understood that if the user plane integrity protection is not enabled, there may be a risk of tampering with user plane data between the UE and the base station. In this case, if the man-in-the-middle exists, authenticity of the user plane data cannot be ensured. Therefore, the man-in-the-middle detection needs to be enabled.

Optionally, if a second preset rule is met, the base station sends indication information to the UE to indicate the UE to enable the man-in-the-middle detection. The second preset rule may be, for example, that a key performance indicator (key performance indicator, KPI) is greater than a second threshold.

S330: The UE sends the first physical frame query request message to the man-in-the-middle.

Specifically, the UE sends, in the physical frame p, the first physical frame query request message that is carried in the RRC message, to perform man-in-the-middle detection. Security protection is performed on the message, and therefore the message cannot be tampered with by the man-in-the-middle.

It should be understood that the first physical frame query request message may be an empty RRC message.

S340: The base station sends fourth DCI to the man-in-the-middle, where the fourth DCI is used to determine a physical frame q.

It should be understood that, before S340, the man-in-the-middle sends the BSR to the base station through false UE, to indicate the data volume of the uplink buffer, and then the base station sends the fourth DCI to the man-in-the-middle, where the fourth DCI is used to determine the physical frame q.

S350: The base station stores frame information of the physical frame q.

Optionally, after indicating the physical frame q to the man-in-the-middle by using the fourth DCI, the base station stores the frame information of the physical frame q.

S360: The man-in-the-middle sends the first physical frame query request message to the base station.

Specifically, the man-in-the-middle receives, in the physical frame p, the first physical frame query request message sent by the UE. Security protection is performed on the first physical frame query request message by using the AS security context established by the UE and the base station, and therefore the man-in-the-middle cannot tamper with the first physical frame query request message, and can only be transparently transmitted to the base station. Therefore, the man-in-the-middle sends, in the physical frame q indicated by the base station for the man-in-the-middle, the first physical frame query request message to the base station.

S370: The base station continues to store the frame information of the physical frame q.

Specifically, after receiving, in the physical frame q, the first physical frame query request message forwarded by the man-in-the-middle, the base station locally records the frame information of the physical frame q, where the frame information of the physical frame q includes a frame number and a subframe number of the physical frame q.

Optionally, when the first physical frame query request message includes specific indication information, for example, the first physical frame query request message is an RRC message for enabling the man-in-the-middle detection, or the first RRC message includes specific indication information (for example, an indication bit is carried in an existing measurement report, and the indication bit optionally indicates to enable the man-in-the-middle detection), the base station continues to retain the frame information of the physical frame q or restores the frame information of the physical frame q.

Optionally, the base station determines, based on the first RRC message, that a terminal enables the man-in-the-middle detection.

It should be understood that a feature that the base station continues to retain the frame information of the physical frame q may be applied to another embodiment in which information about a physical frame needs to be retained. This is not limited in this application.

Optionally, in an NR system, the frame information of the physical frame q may further include a slot number of the physical frame q. In the NR system, when a subframe includes a plurality of slots, the base station (or false base station) may indicate, to the UE by using DCI, the frame number, the subframe number, and the slot number of the physical frame q.

S380: The UE sends the second physical frame query request message to the man-in-the-middle.

Specifically, after sending, in the physical frame p, the first physical frame query request message to the man-in-the-middle, the UE sends the second physical frame query request message on which security protection is performed to the man-in-the-middle, where the second physical frame query request message includes the frame information of the physical frame p. It should be understood that, after determining to enable the man-in-the-middle detection, the UE includes the frame information of the physical frame p in the second physical frame query request message for the man-in-the-middle detection. It should be further understood that the second RRC message is sent to perform a man-in-the-middle detection procedure, so that the base station determines, based on the information about the physical frame carried in the second physical frame query request message, whether the man-in-the-middle exists.

It should be noted that, because the first physical frame query request message is an RRC layer message, when the message is encoded and constructed at an RRC layer, a physical frame in which the message is sent cannot be determined. After the first physical frame query request message is encoded, the first physical frame query request message enters a buffer queue. The UE reports the buffer status report to the base station. Then, the base station schedules the UE in a unified manner. After obtaining a resource, the UE uses the resource for message sending. There is a possibility of retransmission in message sending, and it cannot be ensured that current sending is definitely successful during sending. Therefore, the first physical frame query request message cannot carry the frame information of the physical frame p.

S390: The man-in-the-middle sends the second physical frame query request message to the base station.

Specifically, the man-in-the-middle receives the second physical frame query request message sent by the UE. However, because the second physical frame query request message is sent by the UE based on the AS security context, the man-in-the-middle cannot crack or tamper with the second physical frame query request message, and can only transparently transmit the second physical frame query request message to the base station.

S311: The base station determines whether the physical frame p matches the physical frame q.

Specifically, after receiving the second physical frame request message transparently transmitted by the man-in-the-middle, the base station extracts the frame number and the subframe number of the physical frame p that are carried in the second physical frame query request message, and compares the frame number and the subframe number with the frame number and the subframe number of the physical frame q that are locally recorded and stored. If the frame number of the physical frame p is the same as the frame number of the physical frame q and the subframe number of the physical frame p is the same as the subframe number of the physical frame q, it indicates that the physical frame p matches the physical frame q, and no man-in-the-middle exists between the UE and the base station. Otherwise, it indicates that the physical frame p does not match the physical frame q, and the man-in-the-middle exists between the UE and the base station.

Optionally, in the NR system, when a slot number of a physical frame is considered, the second physical frame query request message carries the frame number, the subframe number, and a slot number of the physical frame p, and compares the frame number, the subframe number, and the slot number with the frame number, the subframe number, and the slot number of the physical frame q that are locally recorded. When the frame number, the subframe number, and the slot number of the physical frame p are respectively the same as the frame number, the subframe number, and the slot number of the physical frame q, it indicates that the physical frame p matches the physical frame q, and no man-in-the-middle exists between the UE and the base station. Otherwise, it indicates that the physical frame p does not match the physical frame q, and the man-in-the-middle exists between the UE and the base station.

Optionally, after determining that the man-in-the-middle exists, the base station may issue a warning or take a preventive measure.

Therefore, according to the man-in-the-middle detection method in this embodiment of this application, man-in-the-middle detection is performed based on that a physical frame in which the man-in-the-middle sends an uplink message through the false UE cannot be consistent with a physical frame in which real UE sends the uplink message, to prevent the man-in-the-middle from bypassing detection through a mechanism of the man-in-the-middle and improve a man-in-the-middle detection rate.

<FIG> is a schematic flowchart of another man-in-the-middle detection method <NUM> according to an embodiment of this application. It can be learned from <FIG> that the method <NUM> includes the following steps.

S410: UE sends, in a third physical frame, a third RRC message to a base station.

S420: The UE receives a fourth RRC message sent by the base station, where the fourth RRC message includes frame information of a fourth physical frame.

S430: The UE determines whether the third physical frame matches the fourth physical frame.

S440: The UE sends a fifth RRC message to the base station, where the fifth RRC message indicates whether the third physical frame matches the fourth physical frame.

Specifically, after successfully establishing an AS security context with the base station, the UE sends, in the third physical frame, the third RRC message on which security protection is performed to the base station, where the third physical frame is a time domain resource specified by the base station (or false base station) for the UE. Security protection is performed on the third RRC message by using the access stratum AS security context established by the UE and the base station. Therefore, a man-in-the-middle cannot crack or tamper with the third RRC message. When a man-in-the-middle attack exists, air interface communication between the UE and the base station is intercepted by the man-in-the-middle. An air interface between the UE and the false base station and an air interface between false UE and the base station are independent of each other, that is, the base station cannot directly receive the third RRC message sent by the UE. The man-in-the-middle receives the third RRC message through the false base station, and forwards the third RRC message to the base station through the false UE. The base station receives, in the fourth physical frame, the third RRC message, and sends the fourth RRC message on which security protection is performed to the UE, where the fourth RRC message includes the frame information of the fourth physical frame. The UE receives the fourth RRC message, obtains the frame information of the fourth physical frame by using the fourth RRC message, and determines whether the third physical frame matches the fourth physical frame. After the man-in-the-middle attack occurs between the UE and the base station, a physical frame in which the UE sends an uplink message cannot be consistent with a physical frame in which the base station receives the uplink message. Therefore, when the third physical frame matches the fourth physical frame, the UE determines that no man-in-the-middle exists between the UE and the base station. When the third physical frame does not match the fourth physical frame, the UE determines that the man-in-the-middle exists between the UE and the base station. Then, the UE sends a fifth RRC message to the base station, where the fifth RRC message indicates whether the third physical frame matches the fourth physical frame.

Therefore, according to the man-in-the-middle detection method in embodiments of this application, whether the man-in-the-middle exists in the air interface communication is determined by determining whether the physical frame in which the UE sends the uplink message matches the physical frame in which the base station receives the uplink message, to prevent the man-in-the-middle from bypassing detection through a mechanism of the man-in-the-middle and improve a man-in-the-middle detection rate.

<FIG> shows a schematic flowchart of a man-in-the-middle detection method <NUM> according to an embodiment of this application when a man-in-the-middle attack exists between UE and a base station. It can be learned from <FIG> that the method <NUM> includes the following steps.

S510: The UE establishes an AS security context with the base station.

Specifically, the UE accesses the base station, that is, the UE establishes an indirect connection to the base station through the man-in-the-middle, and then the UE establishes the access stratum AS security context with the base station. It should be understood that, after the UE establishes the AS security context with the base station, security protection is performed on all RRC messages, and the man-in-the-middle cannot tamper with the RRC message sent between the UE and the base station.

S520: The man-in-the-middle sends fifth DCI to the UE, where the fifth DCI is used to determine a physical frame in which the UE sends an RRC message.

It should be understood that, before S520, the UE sends a buffer status report (buffer status report, BSR) to the man-in-the-middle to indicate a data volume of an uplink buffer, and then the man-in-the-middle sends the fifth DCI to the UE to allocate an appropriate available resource to the UE. The UE determines a physical frame e based on the fifth DCI.

Optionally, the UE locally records frame information of the physical frame e, where the frame information of the physical frame e includes a frame number and a subframe number of the physical frame e.

It should be understood that, before step S520, if a first preset rule is met, the UE enables man-in-the-middle detection. The enabling man-in-the-middle detection means that the UE performs the method mentioned in this application. For example, the enabling man-in-the-middle may include: The UE sends a physical frame query request message and stores the frame information of the physical frame e.

The first preset rule includes: The UE receives indication information from the base station, where the indication information indicates the UE to enable man-in-the-middle detection; or the UE determines that user plane integrity protection between the UE and the base station is not enabled.

S530: The UE sends the physical frame query request message to the man-in-the-middle.

Specifically, the UE sends, in the physical frame e, the physical frame query request message that is carried in the RRC message, to perform man-in-the-middle detection. Security protection is performed on the message by using the access stratum AS security context established between the UE and the base station, and therefore the message cannot be tampered with by the man-in-the-middle.

It should be understood that the physical frame query request message may be an empty RRC message.

S540: The base station sends sixth DCI to the man-in-the-middle, where the sixth DCI is used to determine a physical frame for the man-in-the-middle to perform RRC communication.

Optionally, before S540, the man-in-the-middle sends the buffer status report (buffer status report, BSR) to the base station to indicate the data volume of an uplink buffer. Then, the man-in-the-middle sends the fifth DCI to the UE to allocate an appropriate available resource to the UE. The UE determines a physical frame f based on the sixth DCI.

S550: The man-in-the-middle sends the physical frame query request message to the base station.

Specifically, in S530, the man-in-the-middle receives the physical frame query request message sent by the UE. Because security protection is performed on the message, the man-in-the-middle cannot tamper with the message. Therefore, the man-in-the-middle forwards, in the physical frame f indicated by the base station to the man-in-the-middle, the physical frame query request message to the base station.

S560: The base station sends a physical frame query response message to the man-in-the-middle.

Specifically, after receiving, in the physical frame f, the physical frame query request message transparently transmitted by the man-in-the-middle, the base station sends the physical frame query response message on which security protection is performed to the false UE. The physical frame query response message carries frame information of the physical frame f, where the frame information of the physical frame f includes a frame number and a subframe number of the physical frame f.

S570: The man-in-the-middle sends the physical frame query response message to the UE.

Specifically, after receiving the physical frame query response message sent by the base station, the man-in-the-middle forwards the physical frame query response message to the UE through the false base station.

S580: The UE determines whether the physical frame e matches the physical frame f.

Specifically, after receiving the physical frame query response message sent by the false base station, the UE may extract the frame number and the subframe number of the physical frame f that are carried in the physical frame query response message, and compare the frame number and the subframe number with the frame number and the subframe number of the physical frame e that are locally recorded and stored when the physical frame query request message is successfully sent. If the frame number of the physical frame e is the same as the frame number of the physical frame f and the subframe number of the physical frame e is the same as the subframe number of the physical frame f, it indicates that the physical frame e matches the physical frame f, and no man-in-the-middle exists between the UE and the base station. Otherwise, it indicates that the physical frame e does not match the physical frame f, and the man-in-the-middle exists between the UE and the base station.

S590: The UE sends a physical frame query indication message to the base station.

Specifically, after determining whether the physical frame e matches the physical frame f, the UE sends the physical frame query indication message on which security protection is performed to the base station, and the physical frame query indication message is received by the base station after being transparently transmitted by the man-in-the-middle. The physical frame query indication message includes a determining result, where the determining result indicates whether the physical frame e matches the physical frame f. After determining, based on the physical frame query indication message, that the man-in-the-middle exists, the base station may issue a warning or take a preventive measure.

The methods provided in embodiments of this application are described above in detail with reference to <FIG>. The following describes in detail communication apparatuses provided in embodiments of this application with reference to <FIG> and <FIG>.

<FIG> is a schematic block diagram of a communication apparatus according to an embodiment of this application. As shown in the figure, the communication apparatus <NUM> may include a transceiver module <NUM> and a processing module <NUM>.

In a possible design, the communication apparatus <NUM> may correspond to the base station in the foregoing method embodiments.

Specifically, the communication apparatus <NUM> may correspond to the user equipment in the method <NUM>, the method <NUM>, and the method <NUM> according to embodiments of this application. The communication apparatus <NUM> may include a module configured to perform a method performed by the base station in the method <NUM> in <FIG>, the method <NUM> in <FIG>, or the method <NUM> in <FIG>. In addition, units in the communication apparatus <NUM> and the foregoing other operations and/or functions are separately intended to implement corresponding procedures of the method <NUM> in <FIG>, the method <NUM> in <FIG>, or the method <NUM> in <FIG>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S110 and step S120 in the method <NUM>, and the processing module <NUM> may be configured to perform step S130 in the method <NUM>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S240, step S250, and step S260 in the method <NUM>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S340, step S350, and step S380 in the method <NUM>, and the processing module <NUM> may be configured to perform step S360 and S390 in the method <NUM>.

Specifically, the transceiver module <NUM> is configured to receive, in a first physical frame, a first radio resource control RRC message from user equipment UE. The transceiver module is further configured to receive a second RRC message from the UE, where the second RRC message includes frame information of a second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by the UE and a base station. The processing module is configured to determine whether the first physical frame matches the second physical frame.

Optionally, the processing module <NUM> may be specifically configured to: if a frame number of the first physical frame is the same as a frame number of the second physical frame and a subframe number of the first physical frame is the same as a subframe number of the second physical frame, determine, by the base station, that the first physical frame matches the second physical frame; otherwise, determine, by the base station, that the first physical frame does not match the second physical frame.

Optionally, the processing module <NUM> is further configured to store frame information of a third physical frame.

Optionally, the processing module <NUM> is further configured to establish the AS security context with the UE.

Optionally, the transceiver module <NUM> is further configured to send indication information to the UE, where the indication information indicates the UE to send a fourth RRC message to the base station.

In a possible design, the communication apparatus <NUM> may correspond to the user equipment UE in the foregoing method embodiments or a chip disposed in the UE.

Specifically, the communication apparatus <NUM> may correspond to the base station in the method <NUM>, the method <NUM>, and the method <NUM> according to embodiments of this application. The communication apparatus <NUM> may include a module configured to perform a method performed by the user equipment in the method <NUM> in <FIG>, the method <NUM> in <FIG>, or the method <NUM> in <FIG>. In addition, units in the communication apparatus <NUM> and the foregoing other operations and/or functions are separately intended to implement corresponding procedures of the method <NUM> in <FIG>, the method <NUM> in <FIG>, or the method <NUM> in <FIG>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S110 and step S120 in the method <NUM>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S210, step S220, and step S230 in the method <NUM>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S320, step S330, and step S370 in the method <NUM>.

Specifically, the transceiver module <NUM> is configured to send, in a second physical frame, a first radio resource control RRC message to a base station. The transceiver module is further configured to send a second RRC message to the base station, where the second RRC message includes frame information of the second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by UE and the base station.

Optionally, the transceiver module <NUM> is further configured to receive downlink control information DCI, where the DCI is used to determine the frame information of the second physical frame.

Optionally, the processing module <NUM> is configured to store the frame information of the second physical frame.

Optionally, the processing module <NUM> is further configured to access the base station and establish the AS security context with the base station.

Optionally, the transceiver module <NUM> is specifically configured to: if a preset rule is met, send, by the UE in the second physical frame, the first RRC message to the base station.

Optionally, the processing module <NUM> is further configured to receive indication information sent by the base station, where the indication information indicates the UE to enable man-in-the-middle detection, or determine that user plane integrity protection the base station is not enabled.

In a possible design, the communication apparatus <NUM> may correspond to the user equipment UE in the foregoing method embodiments.

Specifically, the communication apparatus <NUM> may correspond to the base station in the method <NUM> and the method <NUM> according to embodiments of this application. The communication apparatus <NUM> may include a module configured to perform a method performed by the UE in the method <NUM> in <FIG> or the method <NUM> in <FIG>. In addition, units in the communication apparatus <NUM> and the foregoing other operations and/or functions are separately intended to implement corresponding procedures of the method <NUM> in <FIG> or the method <NUM> in <FIG>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S410 and step S420 in the method <NUM>, and the processing module <NUM> may be configured to perform step S430 in the method <NUM>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S520, step S530, step S570, step S590 in the method <NUM>, and the processing module <NUM> may be configured to perform step S580 in the method <NUM>.

Specifically, the transceiver module <NUM> is configured to send, in a third physical frame, a third radio resource control RRC message to a base station. The transceiver module is further configured to receive a fourth RRC message from the base station, where the fourth RRC message includes frame information of a fourth physical frame. The transceiver module is further configured to send a fifth RRC message to the base station, where the fifth RRC message indicates whether the third physical frame matches the fourth physical frame, and security protection is performed on the third RRC message, the fourth RRC message, and the fifth RRC message by using an access stratum AS security context established by UE and the base station.

Optionally, the processing module <NUM> may be specifically configured to: if a frame number of the third physical frame is the same as a frame number of the fourth physical frame and a subframe number of the third physical frame is the same as a subframe number of the fourth physical frame, determine, by the UE, that the third physical frame matches the fourth physical frame; otherwise, determine, by the UE, that the third physical frame does not match the fourth physical frame.

Optionally, the transceiver module <NUM> is further configured to receive downlink control information DCI, where the DCI is used to determine frame information of the third physical frame, and the frame information of the third physical frame includes the frame number and the subframe number of the third physical frame.

Optionally, the processing module <NUM> is further configured to store the frame information of the third physical frame.

Specifically, the communication apparatus <NUM> may correspond to the base station in the method <NUM> and the method <NUM> according to embodiments of this application. The communication apparatus <NUM> may include a module configured to perform a method performed by the base station in the method <NUM> in <FIG> or the method <NUM> in <FIG>. In addition, units in the communication apparatus <NUM> and the foregoing other operations and/or functions are separately intended to implement corresponding procedures of the method <NUM> in <FIG> or the method <NUM> in <FIG>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S410, step S420, and step S440 in the method <NUM>.

When the communication apparatus <NUM> is configured to perform the method <NUM> in <FIG>, the transceiver module <NUM> may be configured to perform step S540, step S550, step S560, step S590 in the method <NUM>, and the processing module <NUM> may be configured to perform step S510 in the method <NUM>.

Specifically, the transceiver module <NUM> is configured to receive, in a fourth physical frame, a third RRC message from user equipment UE. The transceiver module is further configured to send a fourth RRC message to the UE, where the fourth RRC message includes frame information of the fourth physical frame. The transceiver module is further configured to receive a fifth RRC message sent by the UE. The processing module is configured to determine, based on the fifth RRC message, whether a man-in-the-middle exists between a base station and the UE.

Optionally, the processing module <NUM> may be specifically configured to: if a third physical frame does not match the fourth physical frame, determine that the man-in-the-middle exists between the base station and the UE; or if the third physical frame matches the fourth physical frame, determine that no man-in-the-middle exists between the base station and the UE.

Optionally, the processing module <NUM> is further configured to establish an AS security context with the UE.

Optionally, the transceiver module <NUM> is further configured to send indication information to the UE, where the indication information indicates the UE to enable man-in-the-middle detection.

According to the foregoing methods, <FIG> is a schematic diagram of a communication apparatus <NUM> according to an embodiment of this application. As shown in <FIG>, the apparatus <NUM> may be a device that needs to detect a man-in-the-middle and includes various handheld devices, in-vehicle devices, wearable devices, calculating devices that have a wireless communication function, or other processing devices connected to a wireless modem, and various forms of terminals, mobile stations (Mobile Stations, MSs), terminals (Terminals), user equipments UEs, soft terminals, and the like.

The apparatus <NUM> may include a processor <NUM> (that is, an example of a processing module) and a memory <NUM>. The memory <NUM> is configured to store instructions. The processor <NUM> is configured to execute the instructions stored in the memory <NUM>, to enable the apparatus <NUM> to implement a step performed by a network registration device in the method corresponding to <FIG>, <FIG>, <FIG>, or <FIG>.

Further, the apparatus <NUM> may further include an input port <NUM> (that is, an example of a transceiver module) and an output port <NUM> (that is, another example of a transceiver module). Further, the processor <NUM>, the memory <NUM>, the input port <NUM>, and the output port <NUM> may communicate with each other through an internal connection path, to transmit a control signal and/or a data signal. The memory <NUM> is configured to store a computer program. The processor <NUM> may be configured to invoke the computer program from the memory <NUM> and run the computer program, to control the input port <NUM> to receive a signal, and control the output port <NUM> to send a signal, so as to complete a step performed by the terminal device in the foregoing methods. The memory <NUM> may be integrated into the processor <NUM>, or may be disposed separately from the processor <NUM>.

Optionally, if the communication apparatus <NUM> is a communication device, the input port <NUM> is a receiver, and the output port <NUM> is a transmitter. The receiver and the transmitter may be a same physical entity or different physical entities. When the receiver and the transmitter are a same physical entity, the receiver and the transmitter may be collectively referred to as a transceiver.

Optionally, if the communication apparatus <NUM> is a chip or a circuit, the input port <NUM> is an input interface, and the output port <NUM> is an output interface.

In an implementation, it may be considered that functions of the input port <NUM> and the output port <NUM> are implemented by using a transceiver circuit or a dedicated transceiver chip. It may be considered that the processor <NUM> is implemented by using a dedicated processing chip, a processing circuit, a processor, or a general-purpose chip.

In another implementation, it may be considered that the communication device provided in this embodiment of this application is implemented by using a general-purpose computer. To be specific, program code for implementing functions of the processor <NUM>, the input port <NUM>, and the output port <NUM> is stored in the memory <NUM>. The general-purpose processor implements the functions of the processor <NUM>, the input port <NUM>, and the output port <NUM> by executing the code in the memory <NUM>.

Modules or units in the communication apparatus <NUM> may be configured to perform actions or processing processes performed by a device (for example, user equipment) for man-in-the-middle detection in the foregoing methods. To avoid repetition, detailed descriptions thereof are omitted herein.

For concepts, explanations, detailed descriptions, and other steps of the apparatus <NUM> that are related to the technical solutions provided in embodiments of this application, refer to the descriptions related to the content in the foregoing methods or another embodiment.

According to the foregoing methods, <FIG> is a schematic diagram of a communication apparatus <NUM> according to an embodiment of this application. As shown in <FIG>, the apparatus <NUM> may be a man-in-the-middle detection device, and includes a network element having an access management function, for example, an AMF.

The apparatus <NUM> may include a processor <NUM> (that is, an example of a processing module) and a memory <NUM>. The memory <NUM> is configured to store instructions. The processor <NUM> is configured to execute the instructions stored in the memory <NUM>, to enable the apparatus <NUM> to implement a step performed by a device for man-in-the-middle detection in the method corresponding to <FIG>, <FIG>, <FIG>, or <FIG>.

Optionally, if the communication apparatus <NUM> is a communication device, the input port <NUM> is a receiver, and the output port <NUM> is a transmitter. The receiver and the transmitter may be a same physical entity or different physical entities. When the receiver and the transmitter are the same physical entity, the receiver and the transmitter may be collectively referred to as a transceiver.

Modules or units in the communication apparatus <NUM> may be configured to perform actions or processing processes performed by a network-side device (that is, a network device) during network registration in the foregoing methods. To avoid repetition, detailed descriptions thereof are omitted herein.

<FIG> is a schematic diagram of a structure of a terminal device <NUM> according to this application. For ease of description, <FIG> shows only main components of the terminal device. As shown in <FIG>, the terminal device <NUM> includes a processor, a memory, a control circuit, an antenna, and an input/output apparatus.

The processor is mainly configured to process a communication protocol and communication data, control the entire terminal device, execute a software program, and process data of the software program, for example, is configured to support the terminal device in performing actions described in the foregoing embodiments of an indication method for transmitting a precoding matrix. The memory is mainly configured to store a software program and data, for example, store a codebook described in the foregoing embodiments. The control circuit is mainly configured to convert a baseband signal and a radio frequency signal, and process the radio frequency signal. The control circuit and the antenna together may also be referred to as a transceiver, and are mainly configured to receive and send a radio frequency signal in a form of an electromagnetic wave. The input/output apparatus, such as a touchscreen, a display, or a keyboard, is mainly configured to receive data entered by a user and output data to the user.

After the terminal device is powered on, the processor may read a software program in a storage unit, interpret and execute instructions of the software program, and process data of the software program. When data needs to be sent wirelessly, the processor performs baseband processing on to-be-sent data, and then outputs a baseband signal to a radio frequency circuit. The radio frequency circuit performs radio frequency processing on the baseband signal, and then sends, through the antenna, a radio frequency signal in a form of an electromagnetic wave. When data is sent to the terminal device, the radio frequency circuit receives the radio frequency signal through the antenna, converts the radio frequency signal into a baseband signal, and outputs the baseband signal to the processor. The processor converts the baseband signal into data, and processes the data.

A person skilled in the art may understand that, for ease of description, <FIG> shows only one memory and only one processor. In an actual terminal device, there may be a plurality of processors and memories. The memory may also be referred to as a storage medium, a storage device, or the like. This is not limited in embodiments of this application.

In an optional implementation, the processor may include a baseband processor and a central processing unit. The baseband processor is mainly configured to process a communication protocol and communication data. The central processing unit is mainly configured to control the entire terminal device, execute a software program, and process data of the software program. The processor in <FIG> integrates functions of the baseband processor and the central processing unit. A person skilled in the art may understand that the baseband processor and the central processing unit may alternatively be separate processors, and are interconnected by using a technology such as a bus. A person skilled in the art may understand that the terminal device may include a plurality of baseband processors to adapt to different network standards. The terminal device may include a plurality of central processing units to enhance a processing capability of the terminal device. Components of the terminal device may be connected through various buses. The baseband processor may alternatively be expressed as a baseband processing circuit or a baseband processing chip. The central processing unit may alternatively be expressed as a central processing circuit or a central processing chip. A function of processing a communication protocol and communication data may be built in the processor, or may be stored in the storage unit in a form of a software program, and the processor executes the software program to implement a baseband processing function.

As shown in <FIG>, the terminal device <NUM> includes a transceiver unit <NUM> and a processing unit <NUM>. The transceiver unit may also be referred to as a transceiver, a transceiver machine, a transceiver apparatus, or the like. Optionally, a component that is in the transceiver unit <NUM> and that is configured to implement a receiving function may be considered as a receiving unit, and a component that is in the transceiver unit <NUM> and that is configured to implement a sending function may be considered as a sending unit. In other words, the transceiver unit <NUM> includes a receiving unit and a sending unit. For example, the receiving unit may also be referred to as a receiver, a receive machine, or a receiving circuit, and the sending unit may also be referred to as a transmitter, a transmit machine, or a transmitting circuit.

The terminal device shown in <FIG> may perform actions performed by the user equipment in the foregoing method <NUM>, <NUM>, <NUM>, <NUM>, or <NUM>. To avoid repetition, detailed descriptions thereof are omitted herein.

It should be understood that, in embodiments of this application, the processor may be a central processing unit (central processing unit, CPU), or may be another general-purpose processor, a digital signal processor (digital signal processor, DSP), an application-specific integrated circuit (application-specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA), or another programmable logic device, discrete gate, transistor logic device, discrete hardware component, or the like. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor or the like.

It should be further understood that the memory in embodiments of this application may be a volatile memory or a nonvolatile memory, or may include a volatile memory and a nonvolatile memory. The nonvolatile memory may be a read-only memory (Read-only Memory, ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), an electrically erasable programmable read-only memory (Electrically EPROM, EEPROM), or a flash memory. The volatile memory may be a random access memory (Random access memory, RAM), used as an external cache. By way of example, and not limitation, random access memories (Random access memories, RAMs) in many forms may be available, for example, a static random-access memory (Static RAM, SRAM), a dynamic random-access memory (DRAM), a synchronous dynamic random access memory (Synchronous DRAM, SDRAM), a double data rate synchronous dynamic random access memory (Double data rate SDRAM, DDR SDRAM), an enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), a synchlink dynamic random access memory (Synchlink DRAM, SLDRAM), and a direct rambus random access memory (Direct rambus RAM, DR RAM).

All or some of the foregoing embodiments may be implemented by software, hardware, firmware, or any combination thereof. When the software is used to implement the embodiments, the foregoing embodiments may be implemented completely or partially in a form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the program instructions or the computer programs are loaded or executed on a computer, procedures or functions according to embodiments of this application are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or another programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or may be transmitted from a computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by a computer, or a data storage device, such as a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium may be a solid-state drive.

It should be understood that the term "and/or" in this specification describes only an association relationship between associated objects and represents that three relationships may exist. In addition, the character "/" in this specification generally represents an "or" relationship between associated objects.

The execution sequences of the processes should be determined based on functions and internal logic of the processes. This should not be construed as any limitation on the implementation processes of embodiments of this application.

For example, division into the units is merely a logical function division and may be another division during actual implementation. In addition, a displayed or discussed mutual coupling or direct coupling or communication connection may be implemented through some interfaces. An indirect coupling or communication connection between apparatuses or units may be implemented in electronic, mechanical, or other forms.

The units described as separate components may or may not be physically separate, and components displayed as units may or may not be physical units, that is, may be located at one position, or may be distributed on a plurality of network units. Some or all of the units may be selected based on an actual requirement to achieve an objective of the solutions of the embodiments. If the functions are implemented in a form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of this application essentially, or a part contributing to the conventional technology, or some of the technical solutions may be embodied in a form of a software product. The computer software product is stored in a storage medium, and includes several instructions for enabling a computer device (which may be a personal computer, a server, a network device, or the like) to perform all or some of the steps of the methods described in embodiments of this application. The foregoing storage medium includes any medium that can store a program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk, or an optical disc.

Claim 1:
A man-in-the-middle detection method, comprising:
receiving (S110), by a communication apparatus in a first physical frame, a first radio resource control RRC message from user equipment UE;
receiving (S120), by the communication apparatus, a second RRC message from the UE, wherein the second RRC message comprises frame information of a second physical frame, and security protection is performed on the first RRC message and the second RRC message by using an access stratum AS security context established by the UE and the communication apparatus, wherein the security protection comprises RRC confidentiality protection;
determining (S130), by the communication apparatus, whether the first physical frame matches the second physical frame, the determining step comprising;
when the first physical frame matches the second physical frame, determining that no man-in-the-middle exists in the air interface between the UE and the communication apparatus; and
when the first physical frame does not match the second physical frame, determining that a man-in-the-middle exists in the air interface between the UE and the communication apparatus;
wherein the receiving, by a communication apparatus in a first physical frame, a first radio resource control RRC message from user equipment UE comprises:
if a preset rule is met, receiving, by the communication apparatus in the first physical frame, the first RRC message from the UE, wherein the preset rule comprises the communication apparatus determining that user plane integrity protection between the communication apparatus and the UE is not enabled.