Skip to content

Automative threat generation for LLM-agent based systems #1261

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
!td.vue/**/*.scss
!td.vue/public/
!td.vue/public/*
!td.vue/public/**
!td.vue/src/
!td.vue/src/*.js
!td.vue/src/*.vue
Expand Down Expand Up @@ -166,6 +167,9 @@
!td.vue/src/service/threats/models/*.js
!td.vue/src/service/threats/oats/
!td.vue/src/service/threats/oats/*.js
!td.vue/src/service/threats/analyzer/
!td.vue/src/service/threats/analyzer/*.js
!td.vue/src/service/threats/analyzer/*.json
!td.vue/src/service/x6/
!td.vue/src/service/x6/*.js
!td.vue/src/service/x6/graph/
Expand Down
5 changes: 5 additions & 0 deletions td.vue/public/assets/agent-tool.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions td.vue/public/assets/agent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions td.vue/src/components/GraphButtons.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<b-btn-group>

<td-form-button
:onBtnClick="generateThreats"
icon="magic-wand-sparkles"
:title="$t('threatmodel.buttons.generateThreats')"
text="" />

<td-form-button
:onBtnClick="deleteSelected"
icon="trash"
Expand Down Expand Up @@ -73,14 +80,25 @@
import { mapState } from 'vuex';

import TdFormButton from '@/components/FormButton.vue';
import { completeGraphAgentThreats } from '@/service/threats/analyzer/index.js';


export default {
name: 'TdGraphButtons',
components: {
TdFormButton
},
computed: mapState({
cellRef: (state) => state.cell.ref,
threats: (state) => state.cell.threats,
diagram: (state) => state.threatmodel.selectedDiagram,
threatTop: (state) => state.threatmodel.data.detail.threatTop,
disableNewThreat: function (state) {
if (!state.cell?.ref?.data) {
return true;
}
return state.cell.ref.data.outOfScope || state.cell.ref.data.isTrustBoundary || state.cell.ref.data.type === 'tm.Text';
}
}),
data() {
return {
Expand All @@ -93,6 +111,9 @@ export default {
}
},
methods: {
generateThreats() {
completeGraphAgentThreats(this.graph, this.$store);
},
save() {
this.$emit('saved');
},
Expand Down
33 changes: 33 additions & 0 deletions td.vue/src/components/GraphProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@
>
</b-form-group>
</b-col>

<!-- Auto properties -->
<b-col
v-if="cellRef.data.type in properties"
v-for="prop in properties[cellRef.data.type]"
:key="`${cellRef.data.type}_${prop.key}`">
<b-form-group label-cols="auto" :id="`${prop.key}-group`">
<component
:is="propertyTypeComponents[prop.type]"
:id="prop.key"
v-model="cellRef.data[prop.key]"
@change="onChangeProperties()"
>{{ $t(`threatmodel.properties.${prop.key}`) }}</component>
</b-form-group>
</b-col>

</b-form-row>
</b-form>
</div>
Expand All @@ -259,6 +275,23 @@ import dataChanged from '@/service/x6/graph/data-changed.js';

export default {
name: 'TdGraphProperties',
data: () => ({
properties: {
'tm.Agent': [
{ key: 'pQueryRewriting', type: 'bool' },
{ key: 'pPromptTemplate', type: 'bool' },
{ key: 'pAttachInstruction', type: 'bool' },
{ key: 'pOutputSafetyFilter', type: 'bool' },
{ key: 'pModifiesMemory', type: 'bool' },
],
'tm.Flow': [
{ key: 'pRawUserData', type: 'bool' },
]
},
propertyTypeComponents: {
bool: 'b-form-checkbox'
}
}),
computed: mapState({
cellRef: (state) => state.cell.ref
}),
Expand Down
4 changes: 3 additions & 1 deletion td.vue/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
v-b-tooltip.hover :title="$t('nav.logOut')"
></font-awesome-icon>
</b-nav-item>

<b-nav-item
href="https://www.threatdragon.com/docs/"
target="_blank"
Expand Down Expand Up @@ -136,7 +137,8 @@ export default {
throw error;
}
});
}
},

}
};
</script>
11 changes: 10 additions & 1 deletion td.vue/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,17 @@ const eng = {
protocol: 'Protocol',
publicNetwork: 'Public Network',
storesCredentials: 'Stores Credentials',
storesInventory: 'Stores Inventory'
storesInventory: 'Stores Inventory',
pQueryRewriting: 'Query Rewriting',
pPromptTemplate: 'Prompt Template',
pAttachInstruction: 'Attach Instruction',
pOutputSafetyFilter: 'Output Safety Filter',
pModifiesMemory: 'Modifies Memory',
pRawUserData: 'Raw User Data',
},
buttons: {
delete: 'Delete selected',
generateThreats: 'Generate threats',
redo: 'Redo edit',
shortcuts: 'Keyboard shortcuts',
toggleGrid: 'Toggle grid',
Expand Down Expand Up @@ -241,6 +248,8 @@ const eng = {
},
shapes: {
actor: 'Actor',
agent: 'Agent',
tool: 'Tool',
flow: 'Data Flow',
flowStencil: 'Data Flow',
process: 'Process',
Expand Down
3 changes: 3 additions & 0 deletions td.vue/src/i18n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const rus = {
},
buttons: {
delete: 'Delete selected',
generateThreats: 'Generate threats',
redo: 'Redo edit',
shortcuts: 'Keyboard shortcuts',
toggleGrid: 'Toggle grid',
Expand Down Expand Up @@ -236,6 +237,8 @@ const rus = {
},
shapes: {
actor: 'Actor',
agent: 'Agent',
tool: 'Tool',
flow: 'Data Flow',
flowStencil: 'Data Flow',
process: 'Process',
Expand Down
6 changes: 4 additions & 2 deletions td.vue/src/plugins/fontawesome-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
faPrint,
faProjectDiagram,
faDiagramProject,
faLock
faLock,
faMagicWandSparkles
} from '@fortawesome/free-solid-svg-icons';

import {faBitbucket, faGithub, faGitlab, faVuejs, faGoogle, faGoogleDrive} from '@fortawesome/free-brands-svg-icons';
Expand Down Expand Up @@ -70,7 +71,8 @@ library.add(
faDiagramProject,
faGoogle,
faGoogleDrive,
faLock
faLock,
faMagicWandSparkles
);

Vue.component('font-awesome-icon', FontAwesomeIcon);
109 changes: 81 additions & 28 deletions td.vue/src/service/entity/default-properties.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
const actor = {
type: 'tm.Actor',
name: 'Actor',
description: '',
outOfScope: false,
reasonOutOfScope: '',
hasOpenThreats: false,
providesAuthentication: false,
threats: []
};

const boundary = {
type: 'tm.Boundary',
name: 'Trust Boundary',
description: '',
isTrustBoundary: true
};

const boundaryBox = {
type: 'tm.BoundaryBox',
name: 'Trust Boundary',
description: '',
isTrustBoundary: true
};

const flow = {
type: 'tm.Flow',
name: 'Data Flow',
Expand All @@ -34,7 +9,23 @@ const flow = {
isEncrypted: false,
isPublicNetwork: false,
protocol: '',
threats: []
pRawUserData: false,
threats: [],
"isFunctionCall": false,
"isHighFrequency": false,
"resultsAreValidated": true
};

const actor = {
type: 'tm.Actor',
name: 'Actor',
description: '',
outOfScope: false,
reasonOutOfScope: '',
hasOpenThreats: false,
providesAuthentication: false,
threats: [],
isTrusted: false
};

const tmProcess = {
Expand All @@ -48,7 +39,11 @@ const tmProcess = {
handlesGoodsOrServices: false,
isWebApplication: false,
privilegeLevel: '',
threats: []
threats: [],
isTrusted: false,
"hasShortTermMemory": false,
"hasLongTermMemory": false,
"executesGeneratedCode": false
};

const store = {
Expand All @@ -63,16 +58,73 @@ const store = {
isSigned: false,
storesCredentials: false,
storesInventory: false,
threats: []
threats: [],
isTrusted: false,
"isSharedContext": false
};

const agent = {
type: 'tm.Agent',
name: 'Agent',
description: '',
outOfScope: false,
reasonOutOfScope: '',
hasOpenThreats: false,
pQueryRewriting: false,
pPromptTemplate: false,
pAttachInstruction: false,
pOutputSafetyFilter: false,
pModifiesMemory: false,
threats: [],
isTrusted: false,
"hasShortTermMemory": false,
"hasLongTermMemory": false,
"trustScore": 50,
"isRogue": false
};

const tool = {
type: 'tm.Tool',
name: 'Tool',
description: '',
outOfScope: false,
reasonOutOfScope: '',
hasOpenThreats: false,
pRequiresElevatedPrivileges: false,
threats: [],
isTrusted: false,
"isExternal": false,
"isDangerous": false,
"requiresElevatedPrivileges": false
};





const text = {
type: 'tm.Text',
name: 'Descriptive text'
};

const boundary = {
type: 'tm.Boundary',
name: 'Trust Boundary',
description: '',
isTrustBoundary: true
};

const boundaryBox = {
type: 'tm.BoundaryBox',
name: 'Trust Boundary',
description: '',
isTrustBoundary: true
};

const propsByType = {
'tm.Actor': actor,
'tm.Agent': agent,
'tm.Tool': tool,
'tm.Boundary': boundary,
'tm.BoundaryBox': boundaryBox,
'tm.Flow': flow,
Expand All @@ -91,6 +143,7 @@ const getByType = (type) => {

export default {
actor,
agent,
boundary,
boundaryBox,
flow,
Expand Down
Loading