← Learn
Playbook9 min read

Penetration Testing Requirements in Morocco: Law 05-20, DGSSI and Bank Al-Maghrib

Published by Zero Hunt, an autonomous AI red team on an on-premise appliance running private AI: automated penetration testing for networks and infrastructure, black-box or gray-box, with a human approving every step that matters.

Short definition

In Morocco, critical operators (infrastructures d'importance vitale) must have their sensitive systems audited by the DGSSI or a DGSSI-qualified audit provider, penetration testing being one audit domain, each domain at least every three years. Banks must also run a yearly penetration testing programme under Bank Al-Maghrib Directive 3/W/2016 and report on it by 31 March.

Why this matters now

Morocco has two testing regimes that often apply to the same organisation. Law 05-20 and its 2021 decree set audit duties for public bodies and critical operators, with audits reserved to DGSSI-qualified Moroccan providers. Bank Al-Maghrib has required banks to run an annual penetration testing programme since 2016. Both regimes also limit where sensitive data can be hosted, which matters for any testing tool that stores credentials and findings.

Key points

  • ▸Law 05-20 (2020) covers public bodies, critical operators (IIV, public or private) and operators such as telecom carriers and digital service providers. The DGSSI is the national authority (Decree 2-21-406, Art. 1).
  • ▸Sensitive systems of critical operators are audited by the DGSSI or by DGSSI-qualified audit providers. Penetration testing is one of six audit domains, and each domain must be audited at least every three years (Decree 2-21-406, Art. 28 and Annex 2).
  • ▸Qualified audit providers must be Moroccan-law companies with a dedicated audit structure; for the most sensitive systems (class A), majority Moroccan capital and Moroccan auditors.
  • ▸Bank Al-Maghrib Directive 3/W/2016: an annual test programme, tests from inside and outside the network, with and without prior knowledge, more than once a year for internet-facing systems, and a report to Bank Al-Maghrib by 31 March.
  • ▸Sensitive data must be hosted exclusively in Morocco (Law 05-20, Art. 11), and cloud use for sensitive systems requires a DGSSI-qualified cloud provider (Decree 2-24-921).

Who is in scope of Law 05-20

Law 05-20 on cybersecurity (dahir 1-20-69 of 25 July 2020) sets security rules for three groups:

  • Entities: State administrations, local authorities, public establishments and enterprises and other public-law legal persons.
  • Critical operators (infrastructures d'importance vitale, IIV): installations and systems indispensable to vital functions of society, public or private. They are designated sector by sector by the coordinating authority after the DGSSI's opinion, and the list is kept secret (Art. 16). Decree 2-21-406 lists the sectors: among them banking (coordinated by Bank Al-Maghrib), insurance (ACAPS), telecommunications, energy, water, transport and health.
  • Operators: public telecom networks, internet access providers, cybersecurity service providers, digital service providers and internet platforms.

Decree 2-21-406 of 15 July 2021 names the DGSSI (Direction générale de la sécurité des systèmes d'information) as the national authority. For entities, the law requires a security policy that follows DGSSI directives, risk management, classification of systems, a CISO (RSSI) who is the DGSSI's contact, incident declaration and a regularly tested continuity plan. Two audit duties apply directly (Art. 4): every system offering digital services to third parties must be audited before it goes live, and each entity must audit its systems regularly. The same rules apply to critical operators (Art. 14).

A private company that is neither a designated critical operator nor an operator is not directly subject to these audit duties, but its sector regulator may be, as the banking rules below show.

Critical operators: audits by DGSSI-qualified providers

For critical operators, the law and the decree go further.

  • Sensitive systems. Each system is classified A to D by the impact of an incident; class A and B systems are sensitive and must be declared to the DGSSI (Decree, Art. 12). The classification is reviewed at least every three years (Art. 15).
  • Homologation. Every sensitive system needs a security homologation before it goes live, following the DGSSI guide (Law, Art. 19).
  • Audit by domain. Sensitive systems are audited in the domains of Annex 2, where they apply: organisational and physical, architecture, configuration, source code, penetration testing (test d'intrusion) and industrial systems. Each domain must be audited at least every three years (Decree, Art. 28). The decree defines a penetration test as simulating the real conditions of an attack to find vulnerabilities and verify their exploitability and impact.
  • Who audits. The DGSSI itself or a DGSSI-qualified audit provider (prestataire d'audit qualifié), at the operator's cost (Law, Art. 20 and 23). A qualified provider must be a Moroccan-law company with an organisation dedicated exclusively to security audits, qualified in at least three domains with at least one auditor per domain. To audit class A systems, the company must be majority Moroccan-owned and its auditors Moroccan nationals (Decree, Art. 20). Providers are evaluated against the DGSSI qualification référentiel, now version 2.1 (November 2025), and the list of qualified providers is published in the Bulletin officiel and on the DGSSI website (Art. 27).
  • Conduct and reporting. The audit runs under a contract that sets scope, auditors, standards and secure communication channels (Art. 29). The auditor reports imminent, significant flaws immediately (Art. 31), keeps no copy of reports or documents after the mission (Art. 32), and the operator sends the report to the DGSSI (Law, Art. 22), keeps it for at least three years (Decree, Art. 33) and submits an action plan for DGSSI follow-up (Law, Art. 24).

The law also requires critical operators to use security products, services or solutions defined by the DGSSI, and qualified providers when they outsource cybersecurity services (Art. 25).

Banks: Bank Al-Maghrib Directive 3/W/2016

Directive 3/W/2016 of 10 June 2016 sets the minimum rules credit institutions must follow for penetration tests of their information systems. It took effect on signature and is the most detailed testing rule in Morocco:

  • Risk-based programme. Each bank maps its systems' risks of intrusion and cyberattack (Art. 2) and sets an annual test programme covering scope, nature, depth and frequency for primary and backup systems, validated by the audit or risk committee (Art. 3). Scope and frequency follow criticality, the risk analysis and size (Art. 5).
  • Frequency. Systems open to the outside must be tested more than once a year (tests infra-annuels, Art. 6). Tests are also required after any change that may affect exposure, and Bank Al-Maghrib can order targeted tests (Art. 7).
  • How. Tests run from the internal network and from outside (Art. 9), with at least two approaches: without and with prior knowledge of the target, in other words black box and gray box (Art. 10). A charter sets the rules for internal and external teams (Art. 11).
  • Who. The CISO runs the programme (Art. 8). For tests that need confidential information about the systems, the bank should prefer its internal teams, which must have the necessary expertise and certifications, be independent and have enough resources (Art. 12-13). External providers work under a contract; they must keep results confidential, destroy all records within two months with a formal certificate, and may exploit a vulnerability for proof only with the bank's prior, explicit consent and without harming the system (Art. 14-15).
  • Results. Reports to management and the audit or risk committee describe the method and scope, the tests, the vulnerabilities and their impact, the security level against recognised standards and the corrective actions (Art. 17), followed by an action plan (Art. 19).
  • Annual report. By 31 March, each bank sends Bank Al-Maghrib a report with the risk map, the programme carried out, results, the status of action plans and next year's programme (Art. 20).

The directive does not require DGSSI-qualified testers. A bank designated as a critical operator, however, also falls under the Law 05-20 audits above for its sensitive systems. Payment institutions must have security mechanisms that prevent intrusion risk (Circular 6/W/2016, Art. 7), without an explicit penetration testing clause. We did not find a penetration testing rule from the AMMC (capital markets) or ACAPS (insurance) in the texts reviewed; check with your supervisor.

Testing duties at a glance

Rule

Critical operators (IIV)
Decree 2-21-406 Art. 28, Annex 2
Critical operators (IIV)
Law 05-20 Art. 20
Public bodies and IIV
Law 05-20 Art. 4
Banks
BAM Directive 3/W/2016
Banks
BAM Directive 4/W/2022 Art. 20

What must be done

Critical operators (IIV)
Security audit of sensitive systems by domain, penetration testing included
Critical operators (IIV)
Audit of sensitive systems
Public bodies and IIV
Security audit
Banks
Penetration tests from inside and outside, with and without prior knowledge
Banks
Penetration tests of functions outsourced to the cloud

How often

Critical operators (IIV)
Each domain at least every 3 years
Critical operators (IIV)
On DGSSI request
Public bodies and IIV
Regularly, and before go-live of systems offering digital services to third parties
Banks
Annual programme; more than once a year for internet-facing systems; after significant changes
Banks
Under the testing rules; results to BAM

Who may do it

Critical operators (IIV)
DGSSI or DGSSI-qualified audit provider
Critical operators (IIV)
DGSSI or DGSSI-qualified audit provider
Public bodies and IIV
Not specified in the law
Banks
Certified, independent internal teams or an external provider under contract
Banks
As above

Summarized from the texts as read on 20 November 2026 (Bank Al-Maghrib compendium updated to end-2023). Check the official text and your supervisor's guidance before relying on it.

The DNSSI: the baseline for public bodies and critical operators

The Directive nationale de la sécurité des systèmes d'information (DNSSI), issued by the DGSSI under Decree 2-21-406 (Art. 9) and updated in 2023, sets the minimum organisational and technical rules for public bodies and all critical operators, public or private. Entities had six months from publication to set a compliance calendar, and compliance is checked during audits by the DGSSI or qualified auditors.

The rules most relevant to testing:

  • Vulnerability management (EXP-VULN-GEST). A documented process with asset inventory, roles, response times and remediation methods; vulnerabilities judged critical must be reported to the DGSSI.
  • Audits on production systems (EXP-AUDIT-MES). Audit rules (access, permitted checks, auditor authorisation) must be defined, and checks on live systems planned to limit disruption.
  • Security testing in development (DEV-PROC-TEST).
  • Compliance review (CONF-REVU-SSI). Each entity audits the compliance of its systems regularly, follows up with action plans and makes audit reports available to the DGSSI on request.

Bank Al-Maghrib's 2016 directive refers to the DNSSI, and the CISO role it requires is the one defined there.

Cloud and outsourcing

  • Decree 2-24-921 of 22 October 2024. Public bodies and critical operators that use cloud services for sensitive systems or sensitive data must use a DGSSI-qualified cloud provider: level 1 for sensitive systems (hosting infrastructure in Morocco), level 2 for sensitive data (processed and stored exclusively in Morocco, managed from Morocco, majority Moroccan capital, Moroccan staff). The decree applies from the publication of the qualification référentiel, fixed by an arrêté of 1 August 2025; existing users have 24 months to comply. Where no qualified provider offers the service, a non-qualified one can be used temporarily after a documented risk analysis (Art. 17).
  • Bank Al-Maghrib Directive 4/W/2022 of 19 May 2022. Banks must obtain Bank Al-Maghrib's prior approval to move significant functions to the cloud (Art. 12), classify data and define eligible hosting locations, and test the security of outsourced functions with penetration tests whose results go to Bank Al-Maghrib (Art. 20).
  • Law 05-20, Art. 12. Outsourcing a sensitive system requires a Moroccan-law contract with commitments on protection, auditability and reversibility.

Personal data: Law 09-08

Law 09-08 on the protection of individuals with regard to personal data processing (2009), supervised by the CNDP, requires controllers to apply technical and organisational measures that ensure a level of security appropriate to the risks, taking into account the state of the art (Art. 23), with stronger controls for sensitive and health data (Art. 24). Processors must offer sufficient guarantees and act under a contract. Transfers abroad are allowed only to states with sufficient protection, listed by the CNDP, or under the derogations of Art. 44.

The law does not prescribe penetration tests. Testing is the usual evidence that the security measures exist and work, and a test tool that sends results abroad is itself a transfer to assess when those results contain personal data.

Data hosting and the testing tool itself

Law 05-20, Art. 11 is short: sensitive data must be hosted exclusively on national territory. Sensitive data means data classified TRES SECRET or SECRET (Decree 2-21-406, Art. 13). The same decree requires cybersecurity service providers in detection and incident response to host and process sensitive data, and operate their services, only in Morocco (Art. 34).

A penetration test of a sensitive system produces credentials, network maps and step-by-step proof of how to compromise it. How that output is classified is the operator's decision, but if it is sensitive, a SaaS testing platform that stores it abroad, or an AI model hosted overseas that reads it, runs into Art. 11 and Decree 2-24-921. Bank Al-Maghrib also requires external testers to destroy their records within two months. An appliance that runs inside your own data centre, on its own models, keeps the question simple. See the sovereign AI red team guide.

Compliance checklist

  1. Confirm whether you are a designated critical operator, a public body or an operator under Law 05-20, and which supervisor covers your sector.
  2. Classify systems (classes A to D) and data, declare sensitive systems to the DGSSI, and plan homologation before go-live.
  3. For critical operators: plan the Annex 2 audit domains, penetration testing included, so that no domain goes more than three years without an audit, and choose a provider from the DGSSI list of qualified providers.
  4. For banks: map cyber risks, have the annual programme validated by the audit or risk committee, test internet-facing systems more than once a year and after significant changes, and send the report to Bank Al-Maghrib by 31 March.
  5. Use both black-box and gray-box approaches, from inside and outside the network, and set a test charter for internal and external teams.
  6. Report critical vulnerabilities to the DGSSI where the DNSSI applies, track action plans and re-test fixes.
  7. Check where every security tool stores and processes test data, against Law 05-20 Art. 11, Decree 2-24-921 and, for banks, Directive 4/W/2022.

The requirements by regulation page compares Morocco's approach with other jurisdictions.

Where Zero Hunt fits

Zero Hunt is an autonomous AI red team on an on-premise appliance: it runs black-box and gray-box penetration tests of networks and infrastructure from inside your data centre, on its own models, without a third-party LLM, so no customer data leaves your network. A human approves intrusive steps before they run, which matches the prior-consent logic of Directive 3/W/2016. Evidence records are signed and hash-chained, and exported reports are ECDSA-signed.

Zero Hunt is not a DGSSI-qualified audit provider and cannot perform the audits that Law 05-20 and Decree 2-21-406 reserve to the DGSSI and qualified providers; it is not on any DGSSI list of products or services either. It fits between those audits: the internal tests a bank runs under its annual programme, more-than-yearly tests of internet-facing systems, re-tests after changes and after fixes. Zero Hunt maps findings to 34 compliance frameworks, including ISO/IEC 27001, PCI DSS and SWIFT CSP; it has no DNSSI-, DGSSI- or Bank Al-Maghrib-specific mapping, so your team or your qualified partner maps the evidence to those rules.

Questions

Is penetration testing mandatory in Morocco? For banks, yes: Bank Al-Maghrib Directive 3/W/2016 requires an annual programme of penetration tests, more than once a year for internet-facing systems. For critical operators, penetration testing is one of the audit domains of Decree 2-21-406, to be covered at least every three years where it applies to the system.

Who can perform the audit of a critical operator's sensitive systems? The DGSSI or a DGSSI-qualified audit provider: a Moroccan-law company qualified in at least three domains. For class A systems, the company must be majority Moroccan-owned and its auditors Moroccan.

Can a bank test with its own team? Yes. The directive prefers internal teams for tests that need confidential information, provided they are certified, independent and adequately resourced. External providers are allowed under a contract with strict confidentiality and record-destruction clauses.

Do results go to the regulator? Banks send Bank Al-Maghrib an annual report by 31 March, and results of tests on cloud-outsourced functions. Critical operators send audit reports and action plans to the DGSSI.

Can we use a cloud pentest platform hosted outside Morocco? Check first. Sensitive data must be hosted in Morocco, cloud services for sensitive systems or data need a DGSSI-qualified provider, and banks need Bank Al-Maghrib approval for significant cloud functions.

Sources

Goes deeper

Want this against your environment?

Book a 30-minute scoping call — we will map this directly to your current compliance scope and threat profile.