Is CodeNib MCP server safe?
- Possible command injection (shell + dynamic command)
- Unsafe deserialization
- Python shell/command execution
What to do: Read the findings below before installing: each one opens the exact line of code it was found on.
CodeNib MCP server is an MCP server analyzed by SkillTotal's deterministic static scanner. The scan found no malicious indicators, though 2 risky constructs are reported for review. It can: dynamic code execution, filesystem read, filesystem write, mcp tools detected, network egress and shell execution — capabilities are what the code can do, not a verdict on intent. Risk score 40/100 (medium).
codenib 0.2.4
Get notified when this component changes
Change alerts aren't live yet. Leave your email and we'll let you know when they launch. We use it only for this and delete it on request.
Automated static-analysis result. It can contain false positives and false negatives, and is not a claim about the intent of CodeNib MCP server's authors. Report a false positive.
Behavioral traits
How this component maps to the CSA agentic threat model. Descriptive — it never affects the risk score.
Findings (9)
The code builds an OS command out of values that can change at runtime, then runs it through a shell.
proc = subprocess.Popen( # noqa: S602 — loose shell policy by design
command,
shell=True,
cwd=cwd,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess. …Why it matters: If any of those values come from untrusted input, an attacker can run their own commands on the machine.
Fix: Pass arguments as a list without shell=True (e.g. subprocess.run(['git', 'checkout', branch])); never build a shell string from external input. If a shell is unavoidable, quote with shlex.quote.
It loads data with a format that can rebuild arbitrary objects (e.g. pickle, or unsafe YAML).
store._store = pickle.load(f)
cache._cache = pickle.load(f)
payload = pickle.load(handle)
Why it matters: Feeding such a loader untrusted data can execute code hidden inside that data.
Fix: Deserialize untrusted data with a safe format/loader: JSON, or yaml.safe_load / Loader=SafeLoader. Reserve pickle/marshal for data you fully control.
The code turns strings into live code at runtime (eval / new Function / exec).
self._model = self._model.to(device).eval()
_load_lm(
model_name,
dtype=dtype or torch.bfloat16,
model_class=model_class,
attn_implementation="eager",
)
.to(device)
.eval()_load_lm(
model_name,
dtype=dtype or torch.bfloat16,
model_class=model_class,
)
.to(device)
.eval()Why it matters: If those strings aren't fixed and trusted, they become a way to run arbitrary code.
Fix: Avoid evaluating dynamically constructed code; if unavoidable, ensure the input is a trusted constant and never derived from external data.
The component can run operating-system commands or spawn processes.
process = subprocess.Popen(command, cwd=root, stdout=output, stderr=error)
proc = subprocess.Popen( # noqa: S603 - fixed interpreter and module
command,
stdin=subprocess.PIPE,
stdout=stdout_file,
stderr=stderr_file,
start_new_session= …proc = subprocess.Popen( # noqa: S603 - fixed executable and argv
command,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
bufsize=0,
start_new_session=True, …proc = subprocess.Popen( # noqa: S602 — loose shell policy by design
command,
shell=True,
cwd=cwd,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess. …result = subprocess.run(
["git", "-C", str(repo_path), "config", "--get", "remote.origin.url"],
check=True,
capture_output=True,
text=True,
timeout=10,
)result = subprocess.run(command, check=False, capture_output=True)
result = subprocess.run(
[
"git",
"-c",
f"safe.directory={repo}",
"-C",
str(repo),
"rev-parse",
"HEAD", …process = await asyncio.create_subprocess_exec(
*request.argv,
cwd=str(request.cwd),
env=environment,
stdin=(
asyncio.subprocess.PIPE
if …return subprocess.run(
("git", "rev-parse", "HEAD"),
cwd=workspace,
capture_output=True,
text=True,
check=True,
timeout=15,
env={
"GIT_CONFI …return subprocess.run(
("git", "status", "--porcelain=v1", "-z", "--untracked-files=all"),
cwd=request.workspace,
capture_output=True,
check=True,
timeout=30,
).stdoutresult = subprocess.run(
("git", *args),
cwd=cwd,
capture_output=True,
text=True,
check=True,
timeout=60,
env={
"GIT_CONFIG_NOSYSTEM": "1", …return subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=repo_path,
capture_output=True,
text=True,
check=True,
).stdout.strip()return subprocess.run(
("git", *args),
cwd=workspace,
capture_output=True,
text=True,
check=False,
timeout=30,
env=_GIT_ENV,
)result = subprocess.run(
["git", "-C", str(repo_path), "rev-parse", "HEAD"],
capture_output=True,
check=False,
text=True,
)result = subprocess.run(
["git", "-C", repo_path, *args],
capture_output=True,
text=True,
timeout=15,
)result_git = subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=repo_path,
capture_output=True,
text=True,
check=True,
)resolved = subprocess.run(
["git", "-C", repo_path, "rev-parse", "--verify", revision],
check=False,
capture_output=True,
env=_zoekt_git_env(),
)result = subprocess.run(
[
"git",
"-C",
repo_path,
"ls-tree",
"-rz",
"--full-tree",
source_commit,
],
check=False,result = subprocess.run(
["git", "-C", repo_path, "ls-files", "--stage", "-z"],
check=False,
capture_output=True,
env=_zoekt_git_env(),
)result = subprocess.run(
["git", "-C", repo_path, "ls-files", "--others", "-z"],
check=False,
capture_output=True,
env=_zoekt_git_env(),
)process = subprocess.Popen(
["git", "-C", repo_path, "cat-file", "--batch"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
bufsize=0,
env=_z …subprocess.run(
cmd,
check=True,
capture_output=True,
text=True,
env=_zoekt_git_env(), …result = subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=repo_path,
capture_output=True,
text=True,
timeout=5,
)subprocess.run(
[
"git",
"-c",
f"safe.directory={Path(source_repo).expanduser().resolve()}",
"-C",
str(source_repo),
"worktree", …return subprocess.run(
["git", "-c", f"safe.directory={resolved}", "-C", str(repo), *args],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
).stdout. …Why it matters: Powerful and often legitimate — confirm the commands aren't built from untrusted input.
Fix: Confirm the command and its arguments are fully controlled and not derived from untrusted input; avoid shell=True.
The component reads files from disk.
return self.authenticated_snapshot(
relative,
max_bytes=max_bytes,
).read_bytes()with open("/proc/self/mountinfo", encoding="utf-8") as mountinfo:return binding.read_bytes(max_bytes=max_bytes)
return binding.read_bytes(max_bytes=max_bytes)
return path.read_text(encoding="utf-8", errors="replace").splitlines()[line]
source_line = source.read_text(
encoding="utf-8", errors="strict"
).splitlines()[int(line)]with open(cfg) as f:
(self.repo_root / path)
.read_text(encoding="utf-8", errors="replace")raw = source.read_bytes(record.path, max_bytes=10 * 1024 * 1024)
with open(config_file) as f:
skill_doc = skill_md_file.read_text(encoding="utf-8")
with open(file_path, "rb") as fh:
text = file_path.read_text(encoding="utf-8", errors="replace")
with open(file_path, "rb") as fh:
or candidate_metadata.read_bytes() != expected_metadata_bytes
or candidate.read_bytes(
CONTEXT_ARTIFACT_MANIFEST,
max_bytes=expected_metadata_size,
)else reader.read_bytes(path, max_bytes=max_bytes)
payload = reader.read_bytes(
path,
max_bytes=MAX_PORTABLE_DOCUMENTS_JSON_BYTES,
)reader.read_bytes(relative, max_bytes=max_bytes),
payload = reader.read_bytes(relative, max_bytes=_MAX_CONFIG_JSON_BYTES)
payload = reader.read_bytes(relative, max_bytes=_MAX_CONFIG_JSON_BYTES)
lines = resolved.read_text(encoding="utf-8", errors="replace").splitlines()
digest = hashlib.sha256(resolved.read_bytes()).hexdigest()
json.loads(manifest.read_text(encoding="utf-8"))
return __import__("hashlib").sha256(target.read_bytes()).hexdigest()Why it matters: Usually legitimate, but worth confirming it can't be steered into reading sensitive files.
Fix: Confirm which files are read and that paths cannot be influenced by untrusted input to reach sensitive locations.
The component writes or deletes files on disk.
os.unlink(relative.name, dir_fd=parent)
target.write_bytes(text.encode("utf-8"))target.write_bytes(_json_bytes(value))
shutil.copytree(source, destination)
shutil.copy2(source, target)
os.unlink(name, dir_fd=directory_descriptor)
path.write_bytes(_json_bytes(normalized))
config_path.write_bytes(_json_bytes(config))
output.write_bytes(_json_bytes(payload))
config_path.write_bytes(_json_bytes(config))
metadata_path.write_bytes(_json_bytes(metadata))
temporary.write_text(
json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8"
)temporary.write_text(value, encoding="utf-8")
_write_text(prefix.with_suffix(".txt"), attempt.response)_write_text(root / "final-report.md", render_markdown(result))
temporary.write_text(
json.dumps(serialized, indent=2, sort_keys=True) + "\n", encoding="utf-8"
)with open(output_path, "w", encoding="utf-8") as f:
with open(output_path, "w", encoding="utf-8") as f:
temporary.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
os.unlink(occurrence_path)
with open(meta_path, "w") as f:
path.write_text(json.dumps(body, indent=2) + "\n", encoding="utf-8")
os.remove(dataset_path)
with open(self.cache_path, "w", encoding="utf-8") as fh:
with open(cache_path, "w", encoding="utf-8") as f:
Why it matters: Usually legitimate, but worth confirming the paths can't be controlled by untrusted input.
Fix: Confirm which files are written/deleted and that paths cannot be influenced by untrusted input.
The component makes outbound network requests.
import{i as s,s as l,a as m}from"./index-CGflccWM.js";const c=m();async function f(n,e){let t="";try{const r=(await n.text()).trim();if(r)try{const i=JSON.parse(r);t=typeof i.detail=="string"?i.detail:r}catch{t=r}}catch{}const o=t.replace(/ …Why it matters: Usually legitimate, but confirm the destinations are expected and no sensitive data leaves.
Fix: Confirm the destination hosts are expected and that no sensitive data is sent off-host.
The component makes outbound network requests.
import requests
with requests.post(
"https://openrouter.ai/api/v1/chat/completions",
headers={"Authorization": f"Bearer {key}", "X-OpenRouter-Title": "CodeNib"},
json={
"model": config.planner_model, …import urllib.request
parsed = urllib.parse.urlsplit(value.rstrip("/"))return urllib.parse.urlunsplit(parsed)
request = urllib.request.Request(url, headers=_request_headers(token))
opener = urllib.request.build_opener(_NoRedirect())
parsed_download = urllib.parse.urlsplit(download_url)
parsed_api = urllib.parse.urlsplit(api_url)
encoded_name = urllib.parse.urlencode(
{"name": artifact_name, "per_page": 100},
)f"{api_url}/repos/{urllib.parse.quote(owner, safe='')}/"f"{urllib.parse.quote(name, safe='')}/actions/artifacts?{encoded_name}"request = urllib.request.Request(url, headers=_request_headers(token))
opener = urllib.request.build_opener(_NoRedirect())
parsed = urllib.parse.urlsplit(location)
redirected = urllib.request.Request(
location,
headers={"User-Agent": _USER_AGENT},
)with urllib.request.urlopen(redirected, timeout=60) as response:
import requests
self._session = requests.Session()
import requests
response = requests.post(
"https://openrouter.ai/api/alpha/decisions",
headers={
"Authorization": f"Bearer {key.strip()}",
"X-OpenRouter-Title": "CodeNi …import requests
with requests.request(
method,
f"https://openrouter.ai/api/v1/{path}",
headers=headers,
json=payload,
timeout=(5, 20),
allow_redirects=False,
stream=True, …import urllib.request
with urllib.request.urlopen(url, timeout=1.0) as response:
Why it matters: Usually legitimate, but confirm the destinations are expected and no sensitive data leaves.
Fix: Confirm the destination hosts are expected and that no sensitive data is sent off-host.
An MCP tool surface (manifest or tool definitions) was found.
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
@mcp.tool(
Why it matters: Just context — review which tools it offers and their permissions.
Fix: Review the declared MCP tools and their permissions.
How attackers abuse these capabilities
Interactive labs on the attack class behind the rules above. They show the technique, not anything found in CodeNib MCP server.
Check your own component
Run the same evidence-backed scan on any MCP server, agent skill, or package.
Scan your own componentHow we determine this: deterministic static analysis (regex + AST), evidence-anchored, no code execution. Methodology →