CWE-940 Base Incomplet

Improper Verification of Source of a Communication Channel

This vulnerability occurs when an application accepts incoming communication requests without properly checking where they originate from, allowing potentially malicious sources to establish a…

Définition

What is CWE-940?

This vulnerability occurs when an application accepts incoming communication requests without properly checking where they originate from, allowing potentially malicious sources to establish a connection.
When an application fails to verify the true source of a communication channel—such as a network connection, inter-process communication, or API request—it essentially opens a door without checking who's knocking. Attackers can exploit this by spoofing their origin, making malicious traffic appear legitimate, and tricking the system into accepting unauthorized connections. This lack of verification can lead to severe security breaches, including privilege escalation, data theft, or unauthorized access to internal functionality. Developers should implement strong origin validation—like checking IP addresses, using authentication handshakes, or verifying cryptographic signatures—before establishing any communication channel to ensure only trusted sources can interact with the system.
Impact réel

Real-world CVEs caused by CWE-940

  • DNS server can accept DNS updates from hosts that it did not query, leading to cache poisoning

  • DNS server can accept DNS updates from hosts that it did not query, leading to cache poisoning

  • DNS server caches glue records received from non-delegated name servers

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    This Android application will remove a user account when it receives an intent to do so:

  2. 2

    This application does not check the origin of the intent, thus allowing any malicious application to remove a user. Always check the origin of an intent, or create an allowlist of trusted applications using the manifest.xml file.

  3. 3

    These Android and iOS applications intercept URL loading within a WebView and perform special actions if a particular URL scheme is used, thus allowing the Javascript within the WebView to communicate with the application:

  4. 4

    A call into native code can then be initiated by passing parameters within the URL:

  5. 5

    Because the application does not check the source, a malicious website loaded within this WebView has the same access to the API as a trusted site.

Exemple de code vulnérable

Vulnerable Java

This Android application will remove a user account when it receives an intent to do so:

Vulnérable Java
IntentFilter filter = new IntentFilter("com.example.RemoveUser");
  MyReceiver receiver = new MyReceiver();
  registerReceiver(receiver, filter);
  public class DeleteReceiver extends BroadcastReceiver {
  	@Override
  	public void onReceive(Context context, Intent intent) {
  		int userID = intent.getIntExtra("userID");
  		destroyUserData(userID);
  	}
  }
Charge utile de l'attaquant

A call into native code can then be initiated by passing parameters within the URL:

Charge utile de l'attaquant JavaScript
window.location = examplescheme://method?parameter=value
Exemple de code sécurisé

Secure pseudo

Sécurisé pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Liste de contrôle de prévention

How to prevent CWE-940

  • Architecture and Design Use a mechanism that can validate the identity of the source, such as a certificate, and validate the integrity of data to ensure that it cannot be modified in transit using an Adversary-in-the-Middle (AITM) attack. When designing functionality of actions in the URL scheme, consider whether the action should be accessible to all mobile applications, or if an allowlist of applications to interface with is appropriate.
Signaux de détection

How to detect CWE-940

SAST High

Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.

DAST Moderate

Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.

Runtime Moderate

Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.

Code review Moderate

Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-940 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-940 ?

This vulnerability occurs when an application accepts incoming communication requests without properly checking where they originate from, allowing potentially malicious sources to establish a connection.

Quelle est la gravité de CWE-940 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

Quels langages ou plateformes sont affectés par CWE-940 ?

MITRE lists the following affected platforms: Mobile.

Comment puis-je prévenir CWE-940 ?

Use a mechanism that can validate the identity of the source, such as a certificate, and validate the integrity of data to ensure that it cannot be modified in transit using an Adversary-in-the-Middle (AITM) attack. When designing functionality of actions in the URL scheme, consider whether the action should be accessible to all mobile applications, or if an allowlist of applications to interface with is appropriate.

Comment Plexicus détecte et corrige CWE-940 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-940 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-940 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/940.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Faiblesses associées

Weaknesses related to CWE-940

CWE-923 Parent

Improper Restriction of Communication Channel to Intended Endpoints

This vulnerability occurs when a system opens a communication channel for a sensitive task but fails to properly verify that it's actually…

CWE-1275 Frère

Sensitive Cookie with Improper SameSite Attribute

This vulnerability occurs when a sensitive cookie does not have a secure SameSite attribute configured, leaving it exposed to cross-site…

CWE-291 Frère

Reliance on IP Address for Authentication

This vulnerability occurs when a system uses a client's IP address as the sole or primary method to verify their identity.

CWE-297 Frère

Improper Validation of Certificate with Host Mismatch

This vulnerability occurs when an application accepts a valid SSL/TLS certificate without properly verifying that it actually belongs to…

CWE-300 Frère

Channel Accessible by Non-Endpoint

This vulnerability occurs when a system fails to properly verify who is on the other end of a communication link or to secure the channel…

CWE-419 Frère

Unprotected Primary Channel

This vulnerability occurs when an application exposes a privileged administrative interface or restricted functionality through a primary…

CWE-420 Frère

Unprotected Alternate Channel

This vulnerability occurs when an application secures its main communication path but leaves a backup or alternative channel with weaker…

CWE-941 Frère

Incorrectly Specified Destination in a Communication Channel

This vulnerability occurs when an application establishes an outgoing communication channel but fails to correctly define or enforce the…

CWE-942 Frère

Permissive Cross-domain Security Policy with Untrusted Domains

This vulnerability occurs when a web application's cross-domain security policy, like a Content Security Policy (CSP), explicitly allows…

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.