Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KeyError catches on unsafe key accesses with RPC calls #95

Open
wrinklykong opened this issue Aug 11, 2023 · 0 comments
Open

Fix KeyError catches on unsafe key accesses with RPC calls #95

wrinklykong opened this issue Aug 11, 2023 · 0 comments

Comments

@wrinklykong
Copy link

Risky direct Key accesses on results of rpc calls are preformed throughout msfrpc.py and should be changed to .get() to avoid uncaught KeyErrors being thrown.

Examples:

return self.rpc.call(MsfRpcMethod.DbWorkspaces)['workspaces']

https://github.com/DanMcInerney/pymetasploit3/blob/9776da55b0abacfa843a32204f3972ec7d9b3de7/pymetasploit3/msfrpc.py#L1691C16-L1691C16

I suggest doing something like:
val = <rpc_call>.get('<keyname>') if not val: raise Exception

or just surrounded them with a KeyError catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant