Written by Ruben Selby, founder and penetration tester at Wolfcore. Last reviewed 22 November 2026.
Part of the Detection and response section of the Wolfcore Resources library.
In one sentence: Events 5140 and 5145 are the Windows log entries that record someone connecting to a shared folder and then touching files in it, so they help you spot an intruder reading, copying or encrypting your shared data.
What it is
A network share is a folder on one computer that other computers can open, such as \\fileserver\Accounts. Windows can log access to shares in two ways.
- 5140: a network share object was accessed. Microsoft says it is generated once per session, when the first access attempt is made. It sits in the Audit File Share subcategory. For this event the access mask is always 0x1 and the access is always ReadData (or ListDirectory). It tells you “this account connected to this share from this address”. It does not tell you which file.
- 5145: a network share object was checked to see whether the client can be granted the desired access. Microsoft says it is generated every time a file or folder on a share is accessed. It sits in the Audit Detailed File Share subcategory. It includes the relative target name (the file) and the access rights requested.
Think of 5140 as the door being opened and 5145 as each drawer being pulled out.
How it works
- A user or program connects to a share over SMB, the Windows file sharing protocol.
- The server checks the request and, if the Audit File Share subcategory is on, writes 5140 with the account, source IP address, share name and local path.
- For each file or folder opened, and if Audit Detailed File Share is on, it writes 5145 with the file name, access rights and whether the share-level check granted or denied them.
One limit matters. Microsoft states that failure events for 5145 appear only when access is denied at the file share level. If access is denied by the file system permissions (NTFS), no event is generated. A quiet 5145 log does not prove nobody was refused.
Other useful fields: Logon ID (match it to 4624), Source Address, and Share Name. A share name like IPC$ has an empty path. C$ and ADMIN$ are the built-in administrative shares.
Who it affects and how badly
Any business with a Windows file server or a NAS that uses SMB has shares. They are where client files, payroll exports and project drawings live.
- Sole trader to 10 staff (accountancy, legal, trades): often one shared folder on a PC or NAS. Worst case is client files copied out or encrypted, and a duty to tell clients and, where personal data is involved, the regulator.
- 10 to 50 and 50 to 250 staff (recruitment, schools, manufacturing, construction): many shares and many mapped drives. Worst case is a ransomware outage that stops production or lessons for days.
- 250 plus and regulated firms (fintech, insurance, healthcare, councils): shares hold regulated records. Worst case is data theft plus fines under UK GDPR, EU GDPR or US sector rules, and lost clients.
MITRE ATT&CK lists “SMB/Windows Admin Shares” (T1021.002) under Lateral Movement: attackers use valid accounts to interact with a remote share and then act as that user. See how lateral movement works.
Real examples
I have not cited a named incident for these two events, because public reports rarely quote event IDs. The MITRE ATT&CK page above is the primary source for the technique. The case below is an illustration.
Illustration, not a real case. A 40-person building contractor keeps drawings on one server. A stolen password lets an attacker connect from a laptop that has never touched the server before. 5140 shows the account, the laptop’s address and the Drawings share. Minutes later 5145 shows thousands of files opened in sequence. If someone is alerted on the first-ever connection from that laptop, the account is disabled before the copying finishes. If not, the first sign is a ransom note.
What we check on a test
On an internal test we list which shares are reachable from an ordinary staff account, whether the built-in administrative shares are reachable from workstations, and whether any share allows Everyone or Domain Users more than they need. We also check whether share access auditing is on and whether the logs leave the server. We report the gaps. We do not publish findings from other engagements. Our penetration testing service includes this kind of internal check.
Rules and regulators
- UK and EU: UK GDPR and EU GDPR require appropriate security for personal data. File share logs are one way to show you can tell who accessed it. The ICO and your EU supervisory authority publish the exact duties, which I have not reproduced here.
- US: state breach laws and sector rules such as HIPAA apply if the files hold protected data. Check with counsel.
- NCSC (UK): its lateral movement guidance says to enable logging and auditing features on your systems and to use them to detect unusual activity.
How to detect it
Microsoft’s own recommendations for these events are a good start:
- Monitor 5140 and 5145 on high-value machines, for example the C$ share on domain controllers.
- Alert if the Source Address is not from your internal range, or is a machine that should not be able to reach that server.
- On 5145, watch for write-type rights such as WriteData, AppendData, DeleteChild, WRITE_DAC and WRITE_OWNER, especially failures.
- Set a baseline: which accounts and machines normally open which shares. Flag first-time pairings.
- Watch for one source touching many shares or thousands of files in minutes.
5145 is high volume. Turn on Audit Detailed File Share only for the servers and shares that matter, and filter the noise.
How to fix or prevent it
- Give each share the minimum rights. Remove Everyone and broad Domain Users access.
- Block inbound SMB (port 445) at host firewalls except from machines that need it, as in NCSC’s guidance on local firewalls.
- Enable Audit File Share on all file servers and Audit Detailed File Share on sensitive ones.
- Send the logs to a central place.
- Use separate admin accounts so a normal user account cannot open administrative shares.
- Keep file servers patched. See how EternalBlue works.
Frequently asked questions
What is the difference between 5140 and 5145? 5140 logs the share being accessed, once per session. 5145 logs each file or folder checked on that share.
Does 5145 log blocked access? Only when access is denied at the share level. File system (NTFS) denials produce no event.
Why is 5145 so noisy? It is generated every time a file or folder on a share is accessed.
Related terms
how lateral movement works, smb signing, windows event id 4697 service installed, windows event id 4688 process creation, how eternalblue ms17 010 works, port 135 msrpc, Windows Event ID 4663: What It Means and How to Use It
How Wolfcore helps
Wolfcore’s vulnerability management and SOC monitoring keep watch for this after the test is over. See https://wolfcore.co.uk/services/soc-siem-monitoring/
Wolfcore
Would your staff click a phishing email?
Run a real, safe phishing test on your team with Phishy. Free for 14 days, up to 10 staff, no card. We help you set it up.
Start a free phishing testFree website security scanor book a 30 minute call