CWE Rule 1429
R2026bMissing Security-Relevant Feedback for Unexecuted Operations in Hardware Interface
Since R2026b
Description
Missing Security-Relevant Feedback for Unexecuted Operations in Hardware Interface
Polyspace Implementation
The rule checker checks for Returned value of a sensitive function not checked.
Examples
Returned value of a sensitive function not checked occurs when you call a function designated as critical in your code behavior specifications file, but you:
Ignore the return value.
Cast the return value to
void.
This checker requires you to specify which functions in your codebase are
security-critical by using a -code-behavior-specifications datalog
file. In the datalog file, include these components:
Include the definitions in the source file
models/interfaces/sensitive_function.dl.Specify functions as critical:
sensitive_function.is_critical("foo").Specify the datalog file as the input to the option -code-behavior-specifications.
If you do not check the return value of critical functions, security-relevant failures can remain undetected:
Cryptographic operations can fail silently, leading to unencrypted data being transmitted as if it were protected.
Hardware interface functions can discard operations without feedback, masking security breaches or system failures.
Resource allocation functions can fail without notification, causing data loss or system instability.
Capture and check the return value of all functions designated as critical in your
code behavior specifications. Do not cast the return value to void for
critical functions.
In this example, the function encrypt_data is designated as
critical in the code behavior specifications file. The program calls
encrypt_data without capturing its return value.
extern int encrypt_data(const char *input, char *output, int length);
extern void transmit(const char *data, int length);
void process_message(const char *message, int length) {
char encrypted[256];
encrypt_data(message, encrypted, length); // Noncompliant
transmit(encrypted, length);
}The call to encrypt_data can fail without any
feedback. If the encryption operation fails, the program transmits unprocessed data,
potentially exposing sensitive information.
To specify encrypt_data as a critical function, use this datalog
code in a .dl file and specify the file as input to
-code-behavior-specifications:
.include "models/interfaces/sensitive_function.dl"
sensitive_function.is_critical("encrypt_data").One possible correction is to capture and check the return value of
encrypt_data before proceeding with transmission.
#include <stdlib.h>
extern int encrypt_data(const char *input, char *output, int length);
extern void transmit(const char *data, int length);
void process_message(const char *message, int length) {
char encrypted[256];
int result = encrypt_data(message, encrypted, length); // Compliant
if (result != 0) {
/* Handle encryption failure */
abort();
}
transmit(encrypted, length);
}Use the datalog code to specify the critical function:
.include "models/interfaces/sensitive_function.dl"
sensitive_function.is_critical("encrypt_data").Check Information
| Category: Others |
PQL Name:
std.cwe_native.R1429 |
Version History
Introduced in R2026b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)