Vultron Case States Module
vultron.case_states
The vultron.case_states
package implements the CVD Case State Model.
vultron.case_states.hypercube
The vultron.case_states.hypercube
module contains the CVDmodel class, which represents the state graph of a Coordinated Vulnerability Disclosure case.
Based on Householder, A. D., and Jonathan Spring. A State-Based Model for Multi-Party Coordinated Vulnerability Disclosure (MPCVD). Tech. Rep. CMU/SEI-2021-SR-021, Software Engineering Institute, Carnegie-Mellon University, Pittsburgh, PA, 2021.
DESIDERATA = (('V', 'P'), ('V', 'X'), ('V', 'A'), ('F', 'P'), ('F', 'X'), ('F', 'A'), ('D', 'P'), ('D', 'X'), ('D', 'A'), ('P', 'X'), ('P', 'A'), ('X', 'A'))
module-attribute
Taken directly from the paper: Given (A,B), you prefer histories in which A precedes B over ones in which B precedes A.
CVDmodel
A CVDmodel is a graph of states and transitions between them. The model reflects the CVD process and the actions that can be taken at a high level. It also has a set of histories that can be scored.
Source code in vultron/case_states/hypercube.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
|
histories: list
property
A list of all possible case histories traversing the case state space from vfdpxa to VFDPXA.
states: list
property
Returns the states in the model
compute_pagerank()
Compute the pagerank of each state in the model. Runs the NetworkX pagerank algorithm on the model graph 10000 times. Because the model is a directed graph, we need to add a wraparound link so that the pagerank algorithm can walk from the end back to the beginning naturally.
Returns:
Type | Description |
---|---|
dict
|
a dict of state: pagerank |
Source code in vultron/case_states/hypercube.py
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
|
find_states(pat)
Find states that match a given pattern Args: pat: a regex pattern to match
Returns:
Type | Description |
---|---|
list
|
a list of states that match the pattern |
Raises:
Type | Description |
---|---|
CVDmodelError
|
if the pattern is invalid |
Source code in vultron/case_states/hypercube.py
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
|
move_score(from_state, to_state)
Compute the score of moving from one state to another Args: from_state: The state to move from to_state: The state to move to
Returns:
Type | Description |
---|---|
float
|
the score of the move |
Source code in vultron/case_states/hypercube.py
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
|
paths_between(start='vfdpxa', end='VFDPXA')
Return all paths of transitions between two states
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
str
|
the start state, default="vfdpxa" |
'vfdpxa'
|
end |
str
|
the end state, default="VFDPXA" |
'VFDPXA'
|
Returns:
Type | Description |
---|---|
List[tuple]
|
a list of paths |
Source code in vultron/case_states/hypercube.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
paths_from(state='vfdpxa')
Return all paths of transitions that lead from a given state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state to return paths from, default="vfdpxa" |
'vfdpxa'
|
Returns:
Type | Description |
---|---|
List[tuple]
|
a list of paths |
Source code in vultron/case_states/hypercube.py
303 304 305 306 307 308 309 310 311 312 313 314 |
|
paths_to(state='VFDPXA')
Return all paths of transitions that lead to a given state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state to return paths to, default="VFDPXA" |
'VFDPXA'
|
Returns:
Type | Description |
---|---|
List[tuple]
|
a list of paths |
Source code in vultron/case_states/hypercube.py
316 317 318 319 320 321 322 323 324 325 326 327 |
|
previous_state(state)
For a given state, return the previous state(s)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state to return the previous state(s) for |
required |
Returns:
Type | Description |
---|---|
list
|
a list of previous states |
Source code in vultron/case_states/hypercube.py
253 254 255 256 257 258 259 260 261 262 263 264 |
|
score_hist(h)
Compute the score for a given history
Parameters:
Name | Type | Description | Default |
---|---|---|---|
h |
str
|
the history to score |
required |
Returns:
Type | Description |
---|---|
float
|
the score for the history |
Source code in vultron/case_states/hypercube.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
|
sequences_between(start='vfdpxa', end='VFDPXA')
Return all sequences of transitions between two states
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
str
|
the start state, default="vfdpxa" |
'vfdpxa'
|
end |
str
|
the end state, default="VFDPXA" |
'VFDPXA'
|
Returns:
Type | Description |
---|---|
List[str]
|
a list of sequences |
Source code in vultron/case_states/hypercube.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
sequences_from(state='vfdpxa')
Return all sequences of transitions that lead from a given state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state to return sequences from |
'vfdpxa'
|
Returns:
Type | Description |
---|---|
List[str]
|
a list of sequences |
Source code in vultron/case_states/hypercube.py
340 341 342 343 344 345 346 347 348 349 350 |
|
sequences_to(state)
Return all sequences of transitions that lead to a given state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state to return sequences to |
required |
Returns:
Type | Description |
---|---|
List[str]
|
a list of sequences |
Source code in vultron/case_states/hypercube.py
352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
state_adjacency_matrix()
Return the state adjacency matrix for the model
Returns:
Type | Description |
---|---|
DataFrame
|
a dataframe of the state adjacency matrix |
Source code in vultron/case_states/hypercube.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 |
|
state_info(state)
Returns the info for a given state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state to return info for |
required |
Returns:
Type | Description |
---|---|
dict
|
a dict of info for the state |
Source code in vultron/case_states/hypercube.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
state_transition_matrix()
Return the state transition matrix for the model Returns: a dataframe of the state transition matrix
Source code in vultron/case_states/hypercube.py
783 784 785 786 787 788 789 790 791 792 793 794 |
|
transitions_in_path(path)
Return the transitions in a path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
list
|
a list of graph edges |
required |
Returns:
Type | Description |
---|---|
Tuple[str]
|
a tuple of the edge labels |
Source code in vultron/case_states/hypercube.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
walk_from(start=None, end='VFDPXA')
Randomly walk from a given state to a given state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
str
|
the start state, default=None |
None
|
end |
str
|
the end state, default="VFDPXA" |
'VFDPXA'
|
Returns:
Type | Description |
---|---|
tuple
|
a tuple of the path and the probabilities of each step |
Source code in vultron/case_states/hypercube.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
vultron.case_states.states
The vultron.case_states.states
module implements the CVD Case State Model enums.
It also provides functions for converting between state strings and enums.
AttackObservation
Bases: IntEnum
Represents the attack observation state of a case.
Source code in vultron/case_states/states.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
CS_pxa
Bases: Enum
Represents the public state of a case.
pxa
indicates the public is unaware, no exploit has been published, and no attacks have been observed.Pxa
indicates the public is aware, no exploit has been published, and no attacks have been observed.pxA
indicates the public is unaware, no exploit has been published, and attacks have been observed.PxA
indicates the public is aware, no exploit has been published, and attacks have been observed.Pxa
indicates the public is aware, an exploit has been published, and no attacks have been observed.PXA
indicates the public is aware, an exploit has been published, and attacks have been observed.
Note that pXa and pXA are not valid states because once an exploit is published, the public is aware.
Source code in vultron/case_states/states.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
CS_vfd
Bases: Enum
Represents the vendor fix path state of a case.
vfd
indicates the vendor is unaware, no fix is ready and no fix is deployed.Vfd
indicates the vendor is aware, no fix is ready and no fix is deployed.VFd
indicates the vendor is aware, a fix is ready and no fix is deployed.VFD
indicates the vendor is aware, a fix is ready and a fix is deployed.
Source code in vultron/case_states/states.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
ExploitPublication
Bases: IntEnum
Represents the exploit publication state of a case.
Source code in vultron/case_states/states.py
146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
FixDeployment
Bases: IntEnum
Represents the fix deployment state of a case.
Source code in vultron/case_states/states.py
116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
FixReadiness
Bases: IntEnum
Represents the fix readiness state of a case.
Source code in vultron/case_states/states.py
101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
PublicAwareness
Bases: IntEnum
Represents the public awareness state of a case.
Source code in vultron/case_states/states.py
131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
PxaState
Bases: NamedTuple
Represents the public exploit path state of a case.
Source code in vultron/case_states/states.py
197 198 199 200 201 202 |
|
State
Bases: NamedTuple
Represents the state of a case.
Source code in vultron/case_states/states.py
178 179 180 181 182 183 184 185 186 |
|
VendorAwareness
Bases: IntEnum
Represents the vendor awareness state of a case.
Source code in vultron/case_states/states.py
86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
VfdState
Bases: NamedTuple
Represents the vendor fix path state of a case.
Source code in vultron/case_states/states.py
189 190 191 192 193 194 |
|
state_string_to_enum2(s)
Convert a state string to a list of enums that define the state
Example
state_string_to_enum2('vfdpxa')
( VendorAwareness.VENDOR_UNAWARE,
FixReadiness.FIX_NOT_READY,
FixDeployment.FIX_NOT_DEPLOYED,
PublicAwareness.PUBLIC_UNAWARE,
ExploitPublication.NO_PUBLIC_EXPLOIT,
AttackObservation.NO_ATTACKS_OBSERVED)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s |
str
|
the state string |
required |
Returns:
Type | Description |
---|---|
Tuple[Enum]
|
a list of Enums |
Source code in vultron/case_states/states.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
state_string_to_enums(s)
Convert a state string to a tuple of enums that define the state (CS_vfd, CS_pxa)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s |
str
|
the state string |
required |
Returns:
Type | Description |
---|---|
Tuple[Enum]
|
a tuple of enums |
Source code in vultron/case_states/states.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
vultron.case_states.validations
This module contains functions to validate the various strings and patterns used by the CVD State Model
ensure_valid_history(func)
Decorator to ensure a valid history is passed to a function
Example
@ensure_valid_history
def my_func(history, ...):
...
Args: func: the function to decorate
Returns:
Type | Description |
---|---|
Callable
|
the decorated function |
Raises:
Type | Description |
---|---|
HistoryValidationError
|
if the history is invalid |
Source code in vultron/case_states/validations.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
ensure_valid_pattern(func)
Function decorator to ensure a valid pattern is passed to a function
Example
@ensure_valid_pattern
def my_func(pattern, ...):
...
Args: func: the function to decorate
Returns:
Type | Description |
---|---|
Callable
|
the decorated function |
Source code in vultron/case_states/validations.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
ensure_valid_state(func)
Function Decorator to ensure a valid state is passed to a function
Example
@ensure_valid_state
def my_func(state, ...):
...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable
|
the function to decorate |
required |
Returns:
Type | Description |
---|---|
Callable
|
the decorated function |
Source code in vultron/case_states/validations.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
ensure_valid_state_method_wrapper(func)
Method Decorator to ensure a valid state is passed to a method. Equivalent to ensure_valid_state, but for methods.
Example
class MyClass:
@ensure_valid_state_method_wrapper
def my_method(self, state, ...):
...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable
|
the method to decorate |
required |
Returns:
Type | Description |
---|---|
Callable
|
the decorated method |
Source code in vultron/case_states/validations.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
is_valid_history(h)
Validate a history string. Checks that the history is exactly six characters long, is all uppercase, and contains one each of V, F, D, P, X, and A. Also checks that the causally-related events are in the correct order:
- V \(\prec\) F \(\prec\) D
- P \(\prec\) X or XP
- V \(\prec\) P or PV
Example
is_valid_history("VFDPXA")
is_valid_history("VFDPX")
HistoryValidationError
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
h |
str
|
the history string to validate |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
HistoryValidationError
|
if the history is invalid |
Source code in vultron/case_states/validations.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
is_valid_pattern(pat)
Validate a pattern string. Patterns are expected to be regular expressions with the following constraints:
- The pattern is exactly six characters long.
- The pattern contains either upper or lower case v, f, d, p, x, a, in that order, or a dot.
Examples:
is_valid_pattern("vfdpxa")
is_valid_pattern("Vfd.X.")
is_valid_pattern("xpdfva")
is_valid_pattern("vfDPx")
PatternValidationError
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pat |
str
|
the pattern string to validate |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
PatternValidationError
|
if the pattern is invalid |
Source code in vultron/case_states/validations.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
is_valid_state(state)
Validate a state string.
Checks that the state is a valid state pattern.
Also checks that the state is not impossible (e.g. vF....
, .fD...
)
Finally, verifies that only allowed symbols (vVfFdDpPxXaA.
) are used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
the state string to validate |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
StateValidationError
|
if the state is invalid |
Source code in vultron/case_states/validations.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
is_valid_transition(src, dst, allow_null=False)
Validate a transition from src to dst
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
the source state |
required |
dst |
str
|
the destination state |
required |
allow_null |
bool
|
if True, allow null transitions (src==dst), default=False |
False
|
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
TransitionValidationError
|
if the transition is invalid |
Source code in vultron/case_states/validations.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
vultron.case_states.errors
vultron.case_states.errors
provides error classes for the CVD State Model.
CvdStateModelError
Bases: VultronError
Base class for errors in the vultron.case_states
module.
Source code in vultron/case_states/errors.py
21 22 |
|