# VNX-1075: Unconditional Control Flow Transfer outside of Switch Block

A C goto that jumps backwards to a label earlier in the same function.

| Field | Value |
|---|---|
| Rule ID | `VNX-1075` |
| Severity | Low |
| SARIF level | `note` |
| Kind | `sast` |
| Languages | C |
| CWE | [CWE-1075](https://cwe.mitre.org/data/definitions/1075.html) |
| CAPEC | [CAPEC-66](https://capec.mitre.org/data/definitions/66.html) |
| ATT&CK | [T1190](https://attack.mitre.org/techniques/T1190/) |
| CWSS vector | `CWSS:1.0/TI:L/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:L/DI:H/EX:L/EC:N/P:L` |
| Tags | `unconditional-control-flow` `backward-goto` `cwe-1075` |
| Source | [`internal/sast/rules/vnx-1075.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-1075.rego) |

## Overview

VNX-1075 maps to [CWE-1075: Unconditional Control Flow Transfer outside of Switch Block](https://cwe.mitre.org/data/definitions/1075.html). It reports a `goto L;` in a C file (`.c`, `.h`) whose label `L:` is defined earlier in the same function (no column-zero closing brace between them, at most 400 lines above). A retry that jumps forward to an error handler which then jumps back to the label (`try_again: ... goto socket_err; ... socket_err: ... goto try_again;`) is the same loop and is reported too.

The same backward goto in a C++ file (`.cc`, `.cpp`, `.cxx`, `.hpp`, `.hh`) is reported by [VNX-1119](/sast/rules/vnx-1119.md), so one jump is one finding.

It does not report forward gotos to a cleanup or error label (the accepted C error-unwinding idiom), a backward goto into an error-handling tail section (the code after the label returns, exits, continues, breaks or jumps away at the label's own nesting level before reaching the goto, so the jump cannot loop), a goto whose same-named label also appears below it in the function, a same-named label in an earlier function, computed gotos (`goto *ptr`), or goto text in comments (including a `/* */` block whose lines carry no leading `*`) and strings.

## Why this matters

A backward goto is a loop without a loop header: its condition and bound are hidden at the bottom, so it is easy to make it spin forever (an `EINTR` retry with no limit) or to re-run setup that should run once.

## What gets flagged

```c
retry:
    n = read(fd, buf, len);
    if (n < 0 && errno == EINTR)
        goto retry;                         // FLAGGED
```

Not flagged: `if (!buf) goto err_close;` with `err_close:` further down.

## Remediation

1. Write the loop as `for`, `while` or `do { } while`, with an explicit condition and, for retries, a bound.

## References

- [CWE-1075: Unconditional Control Flow Transfer outside of Switch Block](https://cwe.mitre.org/data/definitions/1075.html)

## Suppressing this rule

Put a `nosec` comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file's language (`#`, `//`, `--` or `;`):

```text
# nosec vnx-1075
// nosec vnx-1075
```

Or record an ignore rule: `vulnetix ignore add --rule vnx-1075 --reason "..."`. See [Suppressing findings](/sast/guides/suppressing-findings.md).
