An ADS batch leaf level check and canonical forwarding method based on three-layer length closure

By performing leaf-by-leaf verification and reconstruction of ADS F081 batch write requests in the agent, the problem of boundary interpretation differences between the agent and the target is resolved, ensuring the integrity and security of forwarded messages.

CN123137151APending Publication Date: 2026-11-20BEIJING CHANGDIAN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611327607.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-31
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In ADS F081 bulk write requests, the difference in boundary interpretation between the proxy and the target runtime leads to unauthorized leaf writes and outer authorization masking, which cannot be effectively avoided by existing technologies.

Method used

In the proxy, requests are precisely cut off using AMS/TCP Length, the descriptor area is parsed and the address and length are verified leaf by leaf to form an ordered leaf write vector. New packets are reconstructed and forwarded only when all leaves have passed, ensuring boundary consistency.

Benefits of technology

It achieves consistent boundary interpretation between the agent and the target, avoids unauthorized writes, and ensures the integrity and security of forwarded messages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123137151A_ABST
    Figure CN123137151A_ABST
Patent Text Reader

Abstract

The application discloses a kind of ADS batch leaf level check and specification forwarding method.Proxies cut out request according to AMS / TCP length, verify reserved field, request state, error code and target range, lock the F081 batch write of ReadWrite command and the number N of subcommand, to check the arithmetic calculation 12N byte descriptor area and 4N byte response capacity, prohibit 0xF080-0xF086 recursion, and make descriptor area, leaf data and outer length complete consumption closed.Proxies form ordered leaf write vector, require the whole half-open interval and length of each leaf write to match the same allowed rule;With the vector as the only leaf semantic source of strategy judgment, specification reconstruction and output reanalysis.All leaves are reconstructed and length is recalculated when passing, and are forwarded after consistent reanalysis;Any check, allocation or reanalysis failure is executed before the whole package is blocked, and the original byte is not backed up.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of industrial control network security and industrial communication protocol proxy, specifically to a method deployed between an ADS client and a target ADS server to perform leaf byte boundary closure, leaf address range verification, and specification reconstruction on ADS SumUp batch write containers before forwarding.

[0002] This invention is applicable to ADS communication based on AMS / TCP and can be deployed in transparent security gateways, industrial firewalls, edge proxies, or software-defined test gateways. Background Technology

[0003] ADS supports accessing PLC variables and system services via the ReadWrite command. ADSIGRP_SUMUP_WRITE (0xF081) encapsulates multiple AdsWriteReq subcommands into a single outer ReadWrite request to reduce round trips. The data written consists of N IG, IO, Len triples and N sequentially concatenated data segments.

[0004] Traditional industrial firewalls can allow writes based on the target port, outer command, or outer IndexGroup, and can also resolve the address and length of a single write request. However, when the outer IndexGroup is F081, the actual PLC write effect is generated by multiple leaf write requests within the container. If only outer F081 is authorized, allowed and prohibited leaf writes can be placed in the same batch container.

[0005] Furthermore, AMS / TCP length, AMS DataLength, ReadWrite WriteLength, N represented by IndexOffset, and Len of each leaf collectively describe the same message boundary. If different processors interpret overflow, trailing bytes, recursive SumUp, or unclosed lengths differently, it may lead to parsing discrepancies between the proxy and the target runtime. Summary of the Invention

[0006] The technical problem this invention aims to solve is: how to deterministically expand the outer container into an ordered leaf write vector before a single ADS F081 batch write request reaches the target ADS server, prove that N, the descriptor area, each leaf data slice, and the length of each layer of AMS / TCP are completely consumed and closed, and forward only the new message re-encoded by the leaf vector when the leaf address and length are both approved, thereby avoiding the outer authorization from masking unauthorized leaf writes and the difference in proxy / runtime boundary interpretation.

[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution.

[0008] In the method, the first step is as follows: In the proxy located between the ADS client and the target ADS server, a request with an actual byte count of 6 + Length is precisely cut from the TCP byte stream according to the AMS / TCP Length. It is determined that the AMS / TCP reserved field is 0, the AMS status field is 0x0004, the request ErrorCode is 0, the AMS DataLength is not less than 16 bytes, and the target AMS NetId and the target AMS Port are within the target range of the proxy. It is also limited that CommandId=0x0009, IndexGroup=0xF081 and IndexOffset=N, 1≤N≤500.

[0009] In the method described, the second step involves: using check arithmetic to calculate the descriptor area D=12N and the expected response length R=4N, requiring ReadLength=R, and parsing exactly N little-endian (IG) bytes from the D bytes before writing the data. i IO i ,L i ) descriptor.

[0010] In the method described above, the third step is to disable IG. i Located at 0xF080-0xF086; put IO i and L i Upgrade to at least 64-bit intermediate values, divide into N leaf data slices in the original descriptor order, and require L... i >0、E i =IO i +L i ≤2 32 as well as .

[0011] In the method, the fourth step is to use at least 64-bit intermediate operations with overflow checking to require AMSDataLength=16+WriteLength, AMS / TCP Length=32+16+WriteLength, and the actual number of bytes in the current frame=6+AMS / TCP Length.

[0012] In the method described above, the fifth step involves normalizing each leaf element to its target NetId, target Port, and IG value. i The entire half-open interval [IO] i E i L i and data i The ordered leaf-write vector V is formed in its original order, and V serves as the common and unique source of leaf semantics for allowed rule matching, canonical reconstruction, and output re-parsing consistency verification; only in a single leaf-write target, IGi The entire half-open interval and L i If all leaves match the same allowed rule, the leaf is deemed to pass; if any leaf fails, the entire request is blocked before execution.

[0013] In the method described, step 6 involves: reconstructing the F081 request in the new buffer only when all leaves have passed, maintaining the original order only by the ordered leaf write vector V; writing the verified target AMS NetId and target AMS Port, the source AMS NetId, source AMS Port and InvokeId obtained from the current request message, CommandId=0x0009 and AMS status field=0x0004, and setting the AMS / TCP reserved field and request ErrorCode to 0; recalculating N, ReadLength, WriteLength, AMS DataLength, and AMS / TCP Length by V; re-parseing the output buffer and forwarding after confirming that V and all fields are consistent; blocking without backing up the original request bytes in case of allocation or re-parsing failure.

[0014] The present invention also provides a system corresponding to the aforementioned method, wherein each functional module in the system transmits intermediate results in accordance with the aforementioned processing order and jointly completes the method.

[0015] The TCP stream reassembly module is configured to obtain exactly one complete request based on the AMS / TCP length, and to limit the maximum number of packets and the reassembly timeout.

[0016] The outer filtering module is configured to: determine that the AMS / TCP reserved field is 0, the AMS status field is 0x0004, the request ErrorCode is 0, the AMS DataLength is not less than 16 bytes, and the target AMS NetId and the target AMS Port are within the scope of the agent's responsibility, and verify that CommandId=0x0009 and IndexGroup=0xF081.

[0017] The closed parsing module is configured to use overflow protection to calculate N, D, R, W and each leaf data slice, and verify that the lengths of the three layers are completely consistent.

[0018] The recursive blocking module is configured to: refuse leaf IndexGroup from falling into the SumUp service group of 0xF080-0xF086.

[0019] The leaf-by-leaf strategy module is configured to: form the same ordered leaf write vector V in the original order, and use V as the common and unique source of leaf semantics for allowed rule matching, canonical encoding and output re-parsing consistency verification; it is judged to pass only when the target of the leaf write, IG, the entire IO half-open interval, L and alignment conditions all match the same allowed rule, and if any one of them fails, the entire packet is blocked.

[0020] The standard encoding module is configured to: reconstruct the F081 request in little-endian format only from the same ordered leaf write vector V that has already passed in the new buffer and recalculate the entire length from the same source; block the request when the new buffer allocation fails and do not fall back to the original byte pass-through.

[0021] The present invention also provides an electronic device, the electronic device including a processor, a memory and necessary interfaces, wherein the memory stores a computer program, and the computer program, when executed by the processor, implements the aforementioned method.

[0022] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned method.

[0023] In one alternative implementation, the AMS / TCP reserved field is set to 0, the AMS status field is set to 0x0004, the request ErrorCode is set to 0, the AMS DataLength is set to at least 16 bytes, and the target AMS NetId and the target AMS Port are within the scope of the agent's responsibility.

[0024] In one alternative implementation, the rule can simultaneously define the target Port, IndexGroup, IndexOffset start and end, exact length, maximum length, and alignment granularity.

[0025] In one alternative implementation, single-leaf requests that span two allowed intervals are not allowed to be split and allowed.

[0026] In one alternative implementation, the rejection information includes leaf number, IG, IO, L and rejection reason code, but does not store the sensitive data text.

[0027] In one alternative implementation, the canonical reconstruction sets the AMS / TCP reserved fields and the request ErrorCode to 0, obtains the source AMS NetId, source AMS Port, and InvokeId from the current request message, and writes the verified target AMS NetId and target AMS Port; it does not copy the original descriptor area, original length field, trailing bytes, unknown extension fields, or unverified reserved bits.

[0028] In one alternative implementation, the number of response result codes is exactly N, and the results are mapped to the client in original leaf order.

[0029] In one alternative implementation, the entire packet is blocked when any two leaf write address ranges intersect or descriptors are duplicated.

[0030] In one alternative implementation, the new buffer is re-parsed before sending, and the obtained ordered leaf write vector is verified to be consistent with V item by item. The target AMS NetId and target AMS Port are verified to be equal to the target field verified by the outer layer, and the source AMS NetId, source AMS Port and InvokeId are equal to the corresponding fields obtained from the current request message. CommandId=0x0009, AMS status field=0x0004, AMS / TCP reserved field=0, and request ErrorCode=0.

[0031] In one alternative implementation, if new buffer allocation fails, reparsing fails, or item-by-item consistency is not achieved, the entire request is blocked before any bytes are written to the target ADS server, without falling back to the original byte pass-through.

[0032] In one alternative implementation, the components include an industrial security agent, an industrial gateway, an electronic device, and a storage medium.

[0033] Beneficial effects

[0034] The outer F081 authorization is refined into N leaf address ranges and data lengths that actually produce the PLC writing effect.

[0035] Through D, The same-origin equations for W, AMS DataLength, and AMS / TCP Length eliminate truncation, trailing, and second-boundary interpretation.

[0036] Check arithmetic and recursion-free zones to block integer overflows and nested container bypass paths.

[0037] Full-leaf pass-through gates ensure that unauthorized writes are not mixed in with the same batch of requests.

[0038] Create new messages from leaf vectors without passing through the original bytes, so that the boundaries of the proxy inspection are consistent with the boundaries received by the target at runtime. Attached Figure Description

[0039] Figure 1 A flowchart illustrating the overall process of batch writing leaf-level verification and standardized forwarding methods for ADS.

[0040] Figure 2 This diagram shows the deployment architecture of the ADS client, leaf-level verification agent, and target ADS server. The target ADS server is referred to as the target ADS client in the diagram.

[0041] Figure 3 A byte layout diagram for the AMS / TCP header, AMS header, ReadWrite fixed fields, 12N byte descriptor area, and leaf data area.

[0042] Figure 4 This is a closed-loop diagram showing the relationships between N, D, R, WriteLength, AMS DataLength, and AMS / TCP Length.

[0043] Figure 5 The flowchart shows the process of generating leaf vectors, recursive restricted area verification, and matching leaf-by-leaf allowable rules.

[0044] Figure 6 This is a comparison diagram showing the original F081 request parsing, leaf vector normalization reconstruction, and output re-parsing before and after.

[0045] Figure 7 This diagram illustrates how malformed packets and unauthorized packets trigger pre-execution blocking at different verification stages. Detailed Implementation

[0046] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. The following embodiments are used to illustrate the technical solution of the present invention and are not intended to limit the present invention to a specific software language, processor architecture, operating system or device model.

[0047] Terminology and Data Relationships

[0048] An AMS / TCP request refers to a complete request consisting of a 6-byte AMS / TCP header, a 32-byte AMS header, and ADS command data. In this implementation, the scope of proxy reassembly and the outermost length closure are defined.

[0049] The target ADS server refers to an automated runtime or industrial control device identified by the target AMS NetId and the target AMS Port, which receives ADS requests, executes the requests, and returns ADS responses. In this embodiment, the target ADS server is used to define the request forwarding object of the proxy and the pre-execution blocking boundary, and is not limited to a specific manufacturer, product name, software version, or device model.

[0050] CommandId refers to the ADS command identifier in the AMS header; in the main embodiment of this invention, it is limited to 0x0009ReadWrite. In this embodiment, generalized parsing of other ADS commands is excluded.

[0051] N refers to the number of internal write subcommands represented by the outer indexOffset of F081, limited to 1≤N≤500. In this embodiment, the descriptor area D and the expected response length R are determined.

[0052] D=12N refers to N little-endian triples IG i IO i L i Number of descriptor bytes occupied. In this implementation, a unique offset is determined for the first segment of leaf data.

[0053] W refers to WriteLength in the ReadWrite request. In this implementation, it must be exactly the same as D and the sum of the lengths of all leaf data.

[0054] Leaf-written vector V refers to {target NetId, target Port, IG} arranged in their original order. i IO i L i , data i An ordered sequence. In this implementation, V is the common and unique source of leaf semantics that allows rule matching, canonical reconstruction, and output re-parsing consistency checks.

[0055] The allowed address range refers to the ADS server byte range configured according to the target NetId, target Port, IndexGroup, start and end IndexOffset, allowed length, and alignment rules. In this embodiment, the target, IG... i The entire half-open interval [IO] i E i L i The alignment conditions are jointly determined by the same allowable rule, and leaf writes that cross the boundaries of the allowable interval are not allowed to be split.

[0056] Canonical reconstruction refers to re-encoding the N, descriptor, data, and lengths of each layer of the new F081 request from V without forwarding the original request bytes. The leaf write vector V serves simultaneously as the input for allowing rule matching, the input for canonical encoding, and the consistency comparison benchmark for output re-parsing. This ensures that the leaf boundaries used for policy determination and the leaf boundaries ultimately received by the target ADS server originate from the same semantic object, thereby eliminating boundary differences caused by reinterpreting the original bytes after verification.

[0057] The descriptor and response closure satisfy the following relationship: All multiplications use check arithmetic; R is equal to ReadLength.

[0058] Ye's complete data consumption satisfies the following relationship: The equation must be true exactly; trailing, padded, or truncated bytes are not allowed.

[0059] The AMS layer closure satisfies the following relationship: 16 represents the four 32-bit fields IndexGroup, IndexOffset, ReadLength, and WriteLength in the ReadWrite request.

[0060] The AMS / TCP layer closure satisfies the following relationship: This length does not include the 6-byte AMS / TCP header itself; the actual number of TCP reassembled bytes should be equal to 6 plus this value.

[0061] Leaf address security satisfies the following relationship: , , Both address endpoints and policy endpoints are represented as at least 64-bit half-open intervals; intermediate values ​​are checked first, followed by a full containment check.

[0062] Implementation Method 1: Reassembling and Verifying Outer AMS / TCP Requests

[0063] The proxy, positioned between the ADS client and the target ADS server, precisely segments the TCP byte stream into an AMS / TCP packet of 6+Byte based on the Length field in the AMS / TCP header. The remaining bytes from a single TCP read are reserved for the input of the next AMS / TCP packet and are not incorporated into the current frame. It verifies that the reserved fields in the AMS / TCP header are 0, that the Length does not exceed the configured limit, and obtains a 32-byte AMS header.

[0064] Verify that the AMS status field equals 0x0004, the request ErrorCode equals 0, the CommandId equals 0x0009, the AMSDataLength contains at least 16 bytes of the ReadWrite fixed field, and the target AMS NetId and target AMS Port belong to the targets under the responsibility of this agent. Then read the IndexGroup, IndexOffset, ReadLength, and WriteLength from the ReadWrite fixed field. This method is only entered if IndexGroup equals 0x0000F081.

[0065] Implementation Method 2: Calculate the descriptor area and response capacity

[0066] Interpret IndexOffset as the number of unsigned subcommands N, requiring 1 ≤ N ≤ 500. Use a multiplication check to calculate D = 12N and R = 4N; if multiplication overflows, D exceeds WriteLength, or ReadLength is not equal to R, then reject the operation.

[0067] ReadLength=4N corresponds to N 32-bit result codes in the F081 response. This condition ensures that the requested response capacity and leaf number are source-closed.

[0068] Implementation Method 3: Parse leaf descriptors and delineate data slices

[0069] Parse the first D bytes of data written from ReadWrite into N triplets (IG) in little-endian order. i IO i , L i ). Requirement L i Greater than 0; put the I / O i and L i E is calculated after being upgraded to at least 64-bit unsigned intermediate. i =IO i +L i And require E i ≤2 32 The next data offset is calculated using the same overflow-checking addition. .

[0070] The leaf data area starts at offset D and is defined according to the original descriptor order [data start,i , data start,i +L i Leaf commands cannot be rearranged by address because multiple write operations may have sequential semantics.

[0071] Calculate E i At least 64-bit unsigned intermediate addition overflows, or E i Greater than 2 32 Refusal; E i Equal to 2 32 When permitted.

[0072] Reject if data offset exceeds W or integer overflow occurs.

[0073] Any IG i Reject when located at 0xF080-0xF086 to prevent the leaf from becoming a SumUp container again.

[0074] Implementation Method 4: Perform Multi-Level Byte Consumption Closure

[0075] After completing all leaf segments, a D+ rating is required. It should be exactly equal to WriteLength W; less than W indicates the presence of trailing bytes, and greater than W indicates that the data declared by the descriptor is out of bounds, both of which should be rejected.

[0076] Simultaneously, the AMS DataLength is verified to be exactly 16+W using at least 64-bit intermediate values ​​and addition with overflow checks, the AMS / TCP Length is exactly 32+16+W, and the actual number of bytes in the current frame is exactly 6+AMS / TCP Length. There must be no trailing bytes within the current frame that are not covered by the declared length; subsequent bytes already cut out from the TCP stream are retained for the next frame.

[0077] Implementation Method 5: Leaf-by-Leaf Address and Length Verification

[0078] Normalize each leaf into {target NetId, target Port, valid command ADS Write, IG} i , [IO i E i L i , data i Search for allowed rules item by item, only for the target and IG. i The entire half-open interval, L i When the leaf write is determined to be successful when it matches the same rule as the alignment condition, the entire half-open interval must be contained within the same allowed interval and satisfy the precise length, maximum length, or address alignment granularity specified by the rule.

[0079] Forwarding is only permitted if all leaves pass; if a leaf fails, the original F081 container is either discarded entirely or returns a rejected result locally before reaching the target ADS server. Passing leaves must not be executed first, and failing leaves must not be undone afterward.

[0080] Implementation Method 6: Reconstructing a New Request from the Leaf Vector Specification

[0081] Allocate a new buffer for the leaf write vectors that pass the verification, write N little-endian triples while maintaining the original leaf order, and then write the corresponding data sequentially. i Recalculate N, D, and ... from the actual leaf vectors. ,W,R,AMS DataLength and AMS / TCPLength.

[0082] The new request writes the target AMS NetId and target AMS Port verified by the outer layer, the source AMS NetId, source AMS Port and InvokeId obtained from the current request message, CommandId=0x0009 and AMS status field=0x0004, and sets the AMS / TCP reserved fields and request ErrorCode to 0; it does not copy the original descriptor area, original length field, trailing bytes, unknown extension fields or unverified reserved bits. If the new buffer allocation fails, re-parsing fails, or the V obtained from re-parsing is inconsistent with the V that has passed the verification, the entire request is blocked before any bytes are written to the target ADS server, and the original byte pass-through is not rolled back.

[0083] Example 1: Complete Closure and Reconstruction of Two Legally Written Leaves

[0084] The policy for the target AMS port allows 4-byte writes (IO values ​​0x1000-0x10FF) in IG=0x4020 and 2-byte writes (IO values ​​0x0200-0x02FF) in IG=0x4030. Request N=2, L1=4, L2=2.

[0085] The first step in this embodiment is to calculate D = 12 × 2 = 24, R = 4 × 2 = 8, and W = 24 + 4 + 2 = 30.

[0086] The second step in this embodiment is to verify ReadLength=8, AMS DataLength=16+30=46, and AMS / TCP Length=32+16+30=78.

[0087] The third step in this embodiment is: divide the data into two data slices in the original order, and verify the I / O respectively. i +L i There is no overflow and the values ​​fall completely within their respective allowed ranges.

[0088] The fourth step in this embodiment is to rewrite the two triples and 6 bytes of leaf data in the new buffer, and then forward the data after refilling W, AMS DataLength, and AMS / TCP Length with the actual bytes written.

[0089] The values ​​in this example are used to illustrate deterministic length relationships; they do not constitute a limitation on throughput or latency. The target runtime only receives a single boundary message re-encoded from the verified leaf vector.

[0090] Example 2: Allowed and prohibited leaves are mixed in the same F081 container.

[0091] The first leaf is written to the allowed process variable area, and the second leaf is written to the unauthorized system or output area; the outer F081 itself is located in the allowed command list.

[0092] The first step in this embodiment is to ensure that both the outer format and the total length pass the closure check.

[0093] The second step in this embodiment is: the first leaf matches the allowed rule, and the IG or IO interval of the second leaf does not match any allowed rule.

[0094] The third step in this embodiment is: the agent marks the entire original container as rejected and does not send the first or second leaf to the target ADS server.

[0095] The fourth step in this embodiment is to record the rejection leaf number, IG, IO, and L, but not to record the sensitive data body, for auditing purposes.

[0096] Outer command approval cannot replace leaf write approval; failure of any leaf will block the entire packet, preventing batch containers from masking unauthorized writes.

[0097] Example 3: Malformed Length, Trailing Byte, and Recursive SumUp Blocking

[0098] Using a software message generator, construct messages for cases where N does not match the number of descriptors, and for cases where D is truncated. 1 less than or 1 greater than W, IO i +L i Overflow, Leaf IG i =0xF081, zero-length leaves and trailing data.

[0099] The first step in this embodiment is to change only one variable for each type of malformation and recalculate Ethernet, IP, and TCP checksums simultaneously, so that the test is not intercepted prematurely by the lower-level checksums.

[0100] The second process in this embodiment is to record the unique rejection point of the method in D calculation, descriptor resolution, leaf slicing, multilayer closure, recursive blocking, or policy verification.

[0101] The third step in this embodiment is to input the same message into the comparison agent that only checks the outer F081 layer and the agent of this method, respectively.

[0102] The fourth step in this embodiment is to verify that the method does not forward any malformed raw bytes to the target runtime.

[0103] This embodiment belongs to the deterministic functional test matrix.

[0104] Deterministic software message comparison test results

[0105] The same encoder is used to generate expected allow F081 requests, and 32 fixed-seed variants are generated for each expected rejection category; 5 deterministic boundary allow samples are also reserved. The fixed random seed is 20260830, with a total of 1893 inputs, of which 517 are expected to be allowed and 1376 are expected to be rejected, with the expected rejection samples covering 43 categories. The status field uses the strictly canonical request value 0x0004; 0x0005, 0x000C, and 0x0044 are all rejected before being written to the target connection. The raw bytes, SHA-256, and expected label of each input are fixed at construction time.

[0106] The same input frame is fed into both the constructed reference model and this method. The constructed reference model verifies AMS / TCP and AMS outer closure, the canonical request state, the target, the ReadWrite command, and the outer F081 before allowing writing. This method further performs descriptor area processing, leaf data processing, three-layer full consumption, recursive restricted areas, leaf intervals, leaf-by-leaf strategy, leaf vector re-encoding, and output re-parsing. Allowing is defined as requesting to write to the target ADS server's receive stub, while blocking is defined as returning an explicit rejection before any byte is written to the receive stub. The reference model is only used to isolate incremental effects; the results in the table only reflect the performance of this constructed reference model under the same input.

[0107] Table 1. Results of the deterministic control test on the expected rejection conditions and Ye's request for F081.

[0108] Message Category Sample Count Expected Reference Model Pass This Method Pass This Method Block This Method Disagree with Expectation Expected Pass F081 Request 517 Pass 517 517 0 0 Outer Framing and Screening Rejection 448 Block 0 0 448 0 Inner Layer Closure, Leaf Semantics and Policy Rejection 928 Block 928 0 928 0 Expected Rejection Aggregate 1376 Block 928 0 1376 0

[0109] Calculated using the same denominator, the constructed reference model resulted in a rejection rate of 448 / 1376 (32.56%) for expected rejection samples and a release rate of 928 / 1376 (67.44%). Our method resulted in a release rate of 517 / 517 (100.00%) for expected release samples and a blocking rate of 1376 / 1376 (100.00%) for expected rejection samples, with zero discrepancies from expectations. TCP fragmentation and consecutive frame merging / reassembly tests were both completed with zero residual bytes.

[0110] The results in Table 1 are derived from the software message generator, ADS layer proxy program, and test target ADS server receiver stubs. They are used to verify the deterministic closure, leaf-by-leaf authorization, and pre-execution packet blocking logic of the F081 descriptor area, leaf data area, and the length of each layer of AMS / AMS-TCP. The tests described are not actual throughput, latency, or compatibility measurements performed on a field PLC, real production network, or specific vendor's runtime, and do not imply that any protocol implementation not included in the test matrix will achieve the same results. In this software model, the target AMS NetId and target AMS Port are verified by the outer target range, allowing rules to inherit this fixed target context; the source AMS NetId and source AMS Port are obtained from the current request and remain consistent during specification reconstruction and output re-parsing. This embodiment does not interpret this field retention as source identity authentication. The sample size, message field values, fixed seed, and test order in the table are merely reproduction parameters for this embodiment and do not constitute a limitation on the scope of protection of this invention.

[0111] Exception handling and implementation boundaries

[0112] If CommandId is not 0x0009 and IndexGroup is not 0xF081, it will not enter the main processing chain of this invention and can be processed by other protocol rules.

[0113] The check for arithmetic overflow is rejected when N is 0, greater than 500, or 12N / 4N.

[0114] Reject if ReadLength is not equal to 4N, WriteLength is less than 12N, or any outer layer length is not closed.

[0115] L i 0, IO i +L i Reject if there is overflow, leaf data offset is out of bounds, or final offset is not equal to W.

[0116] When the leaf IG is located between 0xF080 and 0xF086, it is rejected and the same parser is not recursively called.

[0117] Leaf address ranges must fall entirely within an allowed range; leaf segments that cross allowed / prohibited boundaries cannot be split and partially allowed.

[0118] Preserve the original leaf order; do not rearrange write operations that may have a sequential effect in order to obtain a standard order.

[0119] If any leaf fails, the entire package will be blocked before execution, without adopting the approach of execution first and compensation later or reversal afterward.

[0120] The specification reconstruction obtains the source AMS NetId, source AMS Port, and InvokeId from the current request message, writes the verified target AMS NetId and target AMS Port, writes the AMS status field to 0x0004, and writes the AMS / TCP reserved fields and request ErrorCode to 0; it does not copy the original descriptor area, original length field, trailing bytes, unknown extension fields, or unverified reserved bits.

Claims

1. A method for batch write leaf-level verification and canonical forwarding of ADS based on three-layer length closure, characterized in that, This method, applied to a proxy set up between an ADS client and a target ADS server, includes: extracting a current request message from a TCP byte stream based on the Length field in the AMS / TCP header, with the actual number of bytes equal to 6 plus the value of the Length field; reserving bytes in the TCP byte stream exceeding the current request message as input for the next request message; determining that the reserved field in the AMS / TCP header is equal to 0; obtaining 32 bytes of AMS header and ADS command data from the current request message; and determining that the CommandId in the AMS header is equal to 0x0009, the AMS status field is equal to 0x0004, the request ErrorCode is equal to 0, the AMSDataLength is not less than 16 bytes, and the target AMS NetId and target AMS... The port belongs to the target scope of the agent; the IndexGroup, IndexOffset, ReadLength, and WriteLength are obtained from the 16-byte ReadWrite fixed field of the ADS command data, and the IndexGroup is determined to be equal to 0x0000F081. The IndexOffset is taken as the number of subcommands N, and 1≤N≤500 is determined; the descriptor area length D=12N and the expected response length R=4N are calculated by checking arithmetic, and the ReadLength is determined to be equal to R and D is not greater than the WriteLength. Exactly N descriptors are parsed from the first D bytes of the ADS command data in little-endian byte order. Each descriptor includes the first IndexGroup. i IndexOffset IO i Leaf length L i ; Parse the leaf data according to the original order of the N descriptors in the written data, wherein the initial data offset is set to D, and for the i-th descriptor, the IO is... i and L i Convert to at least 64-bit unsigned intermediate value and calculate leaf address endpoint E. i =IO i +L i The next data offset is calculated using check addition; L is determined. i Greater than 0, E i No more than 2 32 IG i The data is not within the closed interval from 0xF080 to 0xF086, the next data offset is not greater than the WriteLength, and the bytes between the current data offset and the next data offset are determined as the i-th leaf data. i After all N leaf data have been parsed, the final data offset is determined to be equal to the WriteLength, such that... Further determination using checksum addition: AMS DataLength = 16 + WriteLength, AMS / TCP Length = 32 + 16 + WriteLength, and the actual number of bytes in the current request message = 6 + AMS / TCP Length; based on the target AMS NetId, target AMS Port, and IG... i A half-open interval [IO] represented by at least 64-bit unsigned endpoints. i E i L i and data i An ordered leaf write vector is generated according to the original order, and this leaf write vector serves as the common and unique source of leaf semantics for allowable rule matching, canonical reconstruction, and output re-parsing consistency verification. It is determined that the half-open address ranges of any two leaf writes with the same target AMSNetId, the same target AMS Port, and the same leaf IndexGroup are non-intersecting, and that there are no duplicate descriptors with the same leaf IndexGroup, leaf IndexOffset, and leaf length among the N descriptors. Each leaf write in the leaf write vector is matched with an allowable rule, which at least specifies the target AMS NetId, target AMS Port, leaf IndexGroup, allowed leaf IndexOffset range, and allowed leaf length conditions. For each leaf write, matching is performed only on the target AMS NetId, target AMS Port, and IG of that leaf write. i Conforms to the same allowable rule, the entire half-open interval [IO] i E i ) is contained within the allowed leaf IndexOffset interval of the same allowed rule, and L i When the allowed leaf length condition of the same allowed rule is met, the leaf write is determined to match the allowed rule; the current request message is determined to pass only when all leaf writes match the allowed rule. If any leaf write does not match, any two half-open address ranges intersect, or there is a duplicate descriptor, the entire current request message is blocked before the target ADS server executes the current request message; only when all leaf writes pass, a new buffer is allocated for the leaf write vector, and N little-endian byte order descriptors and corresponding leaf data are rewritten in the new buffer while maintaining the original order of the leaf write vector. The IndexOffset, ReadLength, WriteLength, AMS DataLength, and AMS / TCP Length are recalculated and written by the leaf write vector. CommandId=0x0009, IndexGroup=0x0000F081, AMS status field=0x0004, source AMS NetId, source AMS Port, and InvokeId obtained from the current request message, and the verified target AMS NetId and target AMS are written. Port, and write AMS / TCP reserved fields and request ErrorCode to 0 to form a new F081 request message; re-parse the new F081 request message; only when the number of subcommands, each descriptor, each leaf data, leaf write order and each layer length relationship obtained by re-parse are consistent with the leaf write vector and the recalculated length relationship item by item, forward the new F081 request message to the target ADS server; if the new buffer allocation fails, the re-parse fails or the item-by-item consistency is not met, block the entire current request message before writing any bytes to the target ADS server, and do not fall back to the original byte pass-through of the current request message; the new F081 request message does not copy the original descriptor area, original length field, trailing byte, unknown extension field or unverified reserved bits.

2. The method according to claim 1, characterized in that, The AMS / TCP Length does not exceed the configured maximum message length; when the AMS / TCP Length exceeds the maximum message length, the current request message is blocked before any bytes are written to the target ADS server.

3. The method according to claim 1, characterized in that, The permission rule further specifies at least one of the following: precise length of leaf write, maximum length, and address alignment granularity, wherein the address alignment granularity requires IO... i It is an integer multiple of the address alignment granularity.

4. The method according to claim 1, characterized in that, Calculate D, R, E i When performing data offsets, WriteLength, AMS DataLength, and AMS / TCP Length operations, all operations must use at least 64-bit unsigned intermediate operations with overflow detection; if any multiplication, addition, or intermediate offset overflows, or E... i Greater than 2 32 At that time, the entire current request message is blocked before execution, where E i Allowed to be equal to 2 32 .

5. The method according to claim 1, characterized in that, When blocking the current request message, record the leaf write sequence number, leaf IndexGroup, leaf IndexOffset, leaf length and rejection reason code of the leaf that failed the verification, but do not record the leaf data body that failed the verification.

6. The method according to claim 1, characterized in that, After the target ADS server returns a response message corresponding to the new F081 request message, it verifies that the number of 32-bit result codes contained in the response message is exactly equal to N, and maps the result codes to the corresponding leaf writes according to the original order of the leaf write vectors before returning them to the ADS client.

7. The method according to claim 1, characterized in that, The output re-parsing further includes: determining that the target AMS NetId and target AMS Port in the new F081 request message are equal to the target AMS NetId and target AMS Port verified by the outer layer, respectively, and that the source AMS NetId, source AMS Port, and InvokeId are equal to the corresponding fields obtained from the current request message, respectively; and determining that CommandId=0x0009, AMS status field=0x0004, AMS / TCP reserved field=0, and request ErrorCode=0; blocking the current request message if any of these are inconsistent.

8. A batch write leaf-level verification and specification forwarding system for ADS based on three-layer length closure, characterized in that, This module, located between the ADS client and the target ADS server, includes a TCP stream reassembly module, an outer filtering module, a closure parsing module, a recursive blocking module, a leaf-by-leaf strategy module, a canonical encoding module, and an output re-parsing module. Specifically: the TCP stream reassembly module is configured to, based on the Length field in the AMS / TCP header, extract the current request packet from the TCP byte stream with an actual byte count equal to 6 plus the Length field value, and reserve the TCP bytes exceeding the current request packet as input for the next request packet, while determining that the AMS / TCP reserved field is equal to 0; the outer filtering module is configured to, from the current request packet, obtain a 32-byte AMS header and a 16-byte ReadWrite fixed field containing IndexGroup, IndexOffset, ReadLength, and WriteLength, and determine that CommandId = 0x0009, AMS status field = 0x0004, request ErrorCode = 0, AMSDataLength is not less than 16 bytes, and the target AMS NetId and target AMS... Port belongs to the target scope of the agent; it is determined that IndexGroup=0x0000F081, IndexOffset is the number of subcommands N, and it is determined that 1≤N≤500; the closing parsing module is configured to use check arithmetic to calculate the descriptor area length D=12N and the expected response length R=4N, determine that ReadLength=R and D is not greater than WriteLength, and parse exactly N bytes including IG from the D bytes before writing data in little-endian byte order. i IO i and L i The descriptor; following the original descriptor order, using D as the initial data offset, E is calculated using at least 64 bits of unsigned intermediate values ​​and checksum addition. i =IO i +L i And the offset of each next data point, to determine L i >0、E i ≤2 32 And obtain the data of each leaf in sequence. i ; Determine after all leaf data has been parsed AMSDataLength = 16 + WriteLength, AMS / TCP Length = 32 + 16 + WriteLength, and the actual number of bytes in the current request packet = 6 + AMS / TCP Length; the recursive blocking module is configured to, in any IG i When the request is within the closed interval of 0xF080 to 0xF086, the entire current request message is blocked; the leaf-by-leaf strategy module is configured to block the request based on the target AMSNetId, target AMS Port, and IG. i Half-open interval [IO i E i L i and data i Generate ordered leaf write vectors according to the original order, and use these ordered leaf write vectors as the common and unique source of leaf semantics for allowed rule matching, canonical encoding, and output re-parsing consistency verification; determine the same target AMS NetId, the same target AMS Port, and IG. i Any two identical half-open address ranges written by leaf are disjoint, and it is determined that IG does not exist among the N descriptors. i IO i and L i All are identical duplicate descriptors; the allowed rules at least limit the target AMS NetId, target AMS Port, and IG. i Allowed leaf index offset range and allowed leaf length conditions, only writing to the target AMS NetId, target AMS Port, and IG on a single leaf. i The entire half-open interval [IO] i E i ) and L i When all leaf writes match the same allowed rule, the leaf write is deemed successful. Only when all leaf writes succeed, the half-open address ranges are disjoint, and there are no duplicate descriptors is a successful result output; otherwise, the entire current request message is blocked before execution. The canonical encoding module is configured to allocate a new buffer only when all leaf writes succeed. Only the ordered leaf write vector rewrites N little-endian byte descriptors and corresponding leaf data in the new buffer, maintaining the original order. The ordered leaf write vector recalculates and writes IndexOffset, ReadLength, WriteLength, AMS DataLength, and AMS / TCP Length. It also writes CommandId=0x0009, IndexGroup=0x0000F081, AMS status field=0x0004, the source AMS NetId, source AMS Port, and InvokeId obtained from the current request message, the verified target AMSNetId, and the target AMS. The port is set to 0, and the AMS / TCP reserved fields and the request ErrorCode are both set to 0 to form a new F081 request message. The new F081 request message does not copy the original descriptor area, the original length field, the trailing byte, the unknown extension field, or the unverified reserved bits. The output re-parsing module is configured to re-parse the new F081 request message and forward it to the target ADS server only if the number of subcommands, each descriptor, each leaf data, the leaf write order, and the length relationship of each layer obtained by re-parsing are consistent with the ordered leaf write vector and the recalculated length relationship item by item. If the new buffer allocation fails, the re-parsing fails, or the item-by-item consistency is not met, the entire current request message is blocked before any byte is written to the target ADS server, and the original byte pass-through of the current request message is not rolled back.

9. An electronic device comprising a processor, a communication interface, a memory, and a computer program stored in the memory and capable of running on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.