SlideShare a Scribd company logo
Model Context Protocol
MCP
Understanding MCP
* What is MCP?
* What problems does MCP solve?
Building Your Own MCP Server
* Step-by-step overview
Attacking MCP Servers
* Common attack techniques
Defending Against MCP Vulnerabilities
* How to protect your environment
AI App
Without MCP
Unique API
Github MCP Server Slack MCP Server
Unique API
Unique API
AI App
AWS MCP Server
With MCP
Github MCP Server Slack MCP Server
AI App
AWS MCP Server
With MCP
Let's look at a basic Example using Claude
Claude + Github
MCP In Depth
Github MCP Server Slack MCP Server
MCP
Client
Custom MCP Server
Your APIs
MCP Servers
Can run either on the same machine or remotely
1. Local MCP Server
2. Remote MCP Server
Local M
Remote
Creating your Own MCP Server
MCP Attacks
We should think of MCP Risks from two angles/use cases
- When you're a Client using an MCP Server
- When you're a Provider building or exposing an MCP Server
When you're a Client using an MCP Server
Tool Poisoning Attack (Indirect Prompt Injection)
MCP Client
Malicious
Currency Server
(Pretending to be Currency Server)
Convert 5 USD to INR Sends
instructions
Perform Currency Conversion...
Send financial.txt to attacker
financial.txt
sent to attacker
Client
User
Tools
Rug Pull Attack
Swaps during use time
MCP Client
Malicious
MCP Server
User
Tools
Orignal MCP Server
Tools
Use Case ===> GitHub MCP Exploited: Accessing private repositories via MCP
source: https://invariantlabs.ai/blog/mcp-github-vulnerability
MCP Server Risks
MCP Server Risks
Prompt Injection
Style Attacks No visibility/observability
Server executes on
end user’s machine
* Tools run with the
user's local privileges.
API tokens exposure Authorization Issues
Local servers typically lack centralized monitoring, logging, or
enforcement mechanisms.
* This makes it hard to audit what tools were called or what
prompts were processed.
When you're a Provider building or exposing an MCP Server
If you are building MCP server - treat all input from LLM/User insecure
Example 1
mcp = FastMCP(
name="UserLookup",
host="0.0.0.0",
port=8081,
)
@mcp.tool()
def lookup(username: str):
conn = sqlite3.connect("users.db")
cursor = conn.cursor()
query = f"SELECT * FROM users WHERE username = '{username}'"
cursor.execute(query)
result = cursor.fetchall()
conn.close()
return result
if __name__ == "__main__":
mcp.run()
SQL Injection
Exploit
{
"tool_name": "lookup",
"args": {
"username": "' OR 1=1 --"
}
}
If you are building MCP server - treat all input from LLM/User insecure
Example 2
# Create the MCP server
mcp = FastMCP(
name="ImageConverter",
host="0.0.0.0",
port=8080,
)
# Expose the vulnerable tool
@mcp.tool()
def convert(filepath: str, format: str):
return convert_image(filepath, format)
# Run the server
if __name__ == "__main__":
mcp.run()
Command Injection
Exploit
{
"tool_name": "convert",
"args": {
"filepath": "image.jpg;cat /etc/passwd >/tmp/leak.txt",
"format": "png"
}
}
Authorization Issues
ALLOWED_TOOLS = {
"admin": ["convert_image", "delete_user", "view_logs"],
"user": ["convert_image"]
}
def authorize(role, tool_name):
return tool_name in ALLOWED_TOOLS.get(role, [])
Example Setup Before executing a tool, check if the caller is
authorized:
if not authorize(current_user_role, tool_name):
raise PermissionError("Unauthorized tool access")
Defending Against MCP Vulnerabilities
How to protect your environment
Two Broad Categories for MCP Security
MCP Security Scanners MCP Gateway
What do we want to protect against
Injection Style Attacks
Tool Poisoning Attack, Rug pulls and tool shadowing, Toxic
Flows.
Gateway should be able to detect these attack during Runtime
and block.
Authorization
Should be able to define per-tool scopes for each MCP Server
MCP Gateway
centralized monitoring, logging, or enforcement mechanisms.
We should be able to define access to MCP Server
depending on groups
Masking/ Privacy
We should be able to token-masking for sensitve data
Obseravability
Users
MCP Gateway
Analyse
LlamaFirewall
Prompt Injection
Block it
Proxy Request
MCP Gateway
MCP Client
MCP Server 1
Tools
MCP Server 2
Tools
MCP Server 3
Tools
Proxy Request
MCP Gateway (OpenSource)
- https://github.com/trailofbits/mcp-context-protector
- https://github.com/lasso-security/mcp-gateway

More Related Content

PDF
apidays Munich 2025 - Let’s build, debug and test a magic MCP server in Postm...
PPTX
Model Context Protocol - path to LLM standartization
PDF
Introduction to Marionette Collective
 
PPTX
How I Developed My First MCP Server? & How You Can Develop It Too?
PPTX
MCP servers development in todays era and how it can be game changer
PDF
Hands on with lightweight m2m and Eclipse Leshan
PPTX
Transform Any Website into a Conversational Experience with NLWeb
PDF
HHM-3540: The IBM MQ Light API: From Developer Laptop to Enterprise Data Cen...
apidays Munich 2025 - Let’s build, debug and test a magic MCP server in Postm...
Model Context Protocol - path to LLM standartization
Introduction to Marionette Collective
 
How I Developed My First MCP Server? & How You Can Develop It Too?
MCP servers development in todays era and how it can be game changer
Hands on with lightweight m2m and Eclipse Leshan
Transform Any Website into a Conversational Experience with NLWeb
HHM-3540: The IBM MQ Light API: From Developer Laptop to Enterprise Data Cen...

Similar to MCP Security Tutorial - Beginner to Advanced (20)

PDF
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
PDF
4Developers: Dominik Przybysz- Message Brokers
PPTX
Hunting for APT in network logs workshop presentation
PDF
The Art of Grey-Box Attack
DOCX
Rpc mechanism
PPTX
Attacks and their mitigations
PPTX
Intro to exploits in metasploitand payloads in msfvenom
ZIP
OneTeam Media Server
DOCX
Backtrack Manual Part6
PDF
Non-functional Test Automation Approach
PDF
Ready Layer One: Intro to the Model Context Protocol
PPT
Node.JS security
PDF
Programming Sessions KU Leuven - Session 02
PDF
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
 
KEY
Cramp websockets
PDF
Manage all the things, small and big, with open source LwM2M implementations ...
PDF
Gauntlt Rugged By Example
PPTX
Spark Streaming Recipes and "Exactly Once" Semantics Revised
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
PPTX
001 implementation nms_software
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
4Developers: Dominik Przybysz- Message Brokers
Hunting for APT in network logs workshop presentation
The Art of Grey-Box Attack
Rpc mechanism
Attacks and their mitigations
Intro to exploits in metasploitand payloads in msfvenom
OneTeam Media Server
Backtrack Manual Part6
Non-functional Test Automation Approach
Ready Layer One: Intro to the Model Context Protocol
Node.JS security
Programming Sessions KU Leuven - Session 02
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
 
Cramp websockets
Manage all the things, small and big, with open source LwM2M implementations ...
Gauntlt Rugged By Example
Spark Streaming Recipes and "Exactly Once" Semantics Revised
Agentforce World Tour Toronto '25 - MCP with MuleSoft
001 implementation nms_software
Ad

Recently uploaded (20)

PPTX
Introduction to Windows Operating System
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
Custom Software Development Services.pptx.pptx
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
"Secure File Sharing Solutions on AWS".pptx
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
 
PDF
Website Design Services for Small Businesses.pdf
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Trending Python Topics for Data Visualization in 2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
Introduction to Windows Operating System
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Topaz Photo AI Crack New Download (Latest 2025)
Custom Software Development Services.pptx.pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Advanced SystemCare Ultimate Crack + Portable (2025)
GSA Content Generator Crack (2025 Latest)
"Secure File Sharing Solutions on AWS".pptx
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
 
Website Design Services for Small Businesses.pdf
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Tech Workshop Escape Room Tech Workshop
How Tridens DevSecOps Ensures Compliance, Security, and Agility
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Oracle Fusion HCM Cloud Demo for Beginners
Monitoring Stack: Grafana, Loki & Promtail
Trending Python Topics for Data Visualization in 2025
Why Generative AI is the Future of Content, Code & Creativity?
Ad

MCP Security Tutorial - Beginner to Advanced

  • 2. Understanding MCP * What is MCP? * What problems does MCP solve? Building Your Own MCP Server * Step-by-step overview Attacking MCP Servers * Common attack techniques Defending Against MCP Vulnerabilities * How to protect your environment
  • 3. AI App Without MCP Unique API Github MCP Server Slack MCP Server Unique API Unique API AI App AWS MCP Server With MCP
  • 4. Github MCP Server Slack MCP Server AI App AWS MCP Server With MCP
  • 5. Let's look at a basic Example using Claude Claude + Github
  • 7. Github MCP Server Slack MCP Server MCP Client Custom MCP Server Your APIs
  • 8. MCP Servers Can run either on the same machine or remotely 1. Local MCP Server 2. Remote MCP Server
  • 10. Creating your Own MCP Server
  • 12. We should think of MCP Risks from two angles/use cases - When you're a Client using an MCP Server - When you're a Provider building or exposing an MCP Server
  • 13. When you're a Client using an MCP Server
  • 14. Tool Poisoning Attack (Indirect Prompt Injection) MCP Client Malicious Currency Server (Pretending to be Currency Server) Convert 5 USD to INR Sends instructions Perform Currency Conversion... Send financial.txt to attacker financial.txt sent to attacker Client User Tools
  • 15. Rug Pull Attack Swaps during use time MCP Client Malicious MCP Server User Tools Orignal MCP Server Tools
  • 16. Use Case ===> GitHub MCP Exploited: Accessing private repositories via MCP source: https://invariantlabs.ai/blog/mcp-github-vulnerability
  • 18. MCP Server Risks Prompt Injection Style Attacks No visibility/observability Server executes on end user’s machine * Tools run with the user's local privileges. API tokens exposure Authorization Issues Local servers typically lack centralized monitoring, logging, or enforcement mechanisms. * This makes it hard to audit what tools were called or what prompts were processed.
  • 19. When you're a Provider building or exposing an MCP Server
  • 20. If you are building MCP server - treat all input from LLM/User insecure Example 1 mcp = FastMCP( name="UserLookup", host="0.0.0.0", port=8081, ) @mcp.tool() def lookup(username: str): conn = sqlite3.connect("users.db") cursor = conn.cursor() query = f"SELECT * FROM users WHERE username = '{username}'" cursor.execute(query) result = cursor.fetchall() conn.close() return result if __name__ == "__main__": mcp.run() SQL Injection Exploit { "tool_name": "lookup", "args": { "username": "' OR 1=1 --" } }
  • 21. If you are building MCP server - treat all input from LLM/User insecure Example 2 # Create the MCP server mcp = FastMCP( name="ImageConverter", host="0.0.0.0", port=8080, ) # Expose the vulnerable tool @mcp.tool() def convert(filepath: str, format: str): return convert_image(filepath, format) # Run the server if __name__ == "__main__": mcp.run() Command Injection Exploit { "tool_name": "convert", "args": { "filepath": "image.jpg;cat /etc/passwd >/tmp/leak.txt", "format": "png" } }
  • 22. Authorization Issues ALLOWED_TOOLS = { "admin": ["convert_image", "delete_user", "view_logs"], "user": ["convert_image"] } def authorize(role, tool_name): return tool_name in ALLOWED_TOOLS.get(role, []) Example Setup Before executing a tool, check if the caller is authorized: if not authorize(current_user_role, tool_name): raise PermissionError("Unauthorized tool access")
  • 23. Defending Against MCP Vulnerabilities How to protect your environment
  • 24. Two Broad Categories for MCP Security MCP Security Scanners MCP Gateway
  • 25. What do we want to protect against Injection Style Attacks Tool Poisoning Attack, Rug pulls and tool shadowing, Toxic Flows. Gateway should be able to detect these attack during Runtime and block. Authorization Should be able to define per-tool scopes for each MCP Server MCP Gateway centralized monitoring, logging, or enforcement mechanisms. We should be able to define access to MCP Server depending on groups Masking/ Privacy We should be able to token-masking for sensitve data Obseravability
  • 26. Users MCP Gateway Analyse LlamaFirewall Prompt Injection Block it Proxy Request MCP Gateway MCP Client MCP Server 1 Tools MCP Server 2 Tools MCP Server 3 Tools Proxy Request
  • 27. MCP Gateway (OpenSource) - https://github.com/trailofbits/mcp-context-protector - https://github.com/lasso-security/mcp-gateway